home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Periodicals / CSMP / C.S.M.P. Digest, Issue 3.020 < prev    next >
Internet Message Format  |  1994-06-09  |  104KB

  1. From: pottier@clipper.ens.fr (Francois Pottier)
  2. Subject: csmp-digest-v3-020
  3. Date: Wed, 27 Apr 94 17:01:22 MET DST
  4.  
  5. C.S.M.P. Digest             Wed, 27 Apr 94       Volume 3 : Issue 20
  6.  
  7. Today's Topics:
  8.  
  9.         Can background app Paste?
  10.         Determing selected-chosen printer
  11.         Drawing text vertically...
  12.         HELP! Sending apple events
  13.         How can I LOCK in a code segment ?
  14.         INIT vs. Background Only App.
  15.         Info on Graphics Animation Programming?
  16.         Launching an application from a program...
  17.         Looking for a Windows-Mac portable GUI toolkit or builder
  18.         PowerPC Anti-Aliased Text
  19.         SubLaunching applications and DA's
  20.         System 7 Menu on right side of menubar
  21.         free vs. DisposPtr??
  22.  
  23.  
  24.  
  25. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  26. (pottier@clipper.ens.fr).
  27.  
  28. The digest is a collection of article threads from the internet newsgroup
  29. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  30. regularly and want an archive of the discussions.  If you don't know what a
  31. newsgroup is, you probably don't have access to it.  Ask your systems
  32. administrator(s) for details.  If you don't have access to news, you may
  33. still be able to post messages to the group by using a mail server like
  34. anon.penet.fi (mail help@anon.penet.fi for more information).
  35.  
  36. Each issue of the digest contains one or more sets of articles (called
  37. threads), with each set corresponding to a 'discussion' of a particular
  38. subject.  The articles are not edited; all articles included in this digest
  39. are in their original posted form (as received by our news server at
  40. nef.ens.fr).  Article threads are not added to the digest until the last
  41. article added to the thread is at least two weeks old (this is to ensure that
  42. the thread is dead before adding it to the digest).  Article threads that
  43. consist of only one message are generally not included in the digest.
  44.  
  45. The digest is officially distributed by two means, by email and ftp.
  46.  
  47. If you want to receive the digest by mail, send email to listserv@ens.fr
  48. with no subject and one of the following commands as body:
  49.     help                        Sends you a summary of commands
  50.     subscribe csmp-digest Your Name    Adds you to the mailing list
  51.     signoff csmp-digest            Removes you from the list
  52. Once you have subscribed, you will automatically receive each new
  53. issue as it is created.
  54.  
  55. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  56. Questions related to the ftp site should be directed to
  57. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  58. digest are available there.
  59.  
  60. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  61.  
  62.  
  63. -------------------------------------------------------
  64.  
  65. >From west@augsburg.edu (James West)
  66. Subject: Can background app Paste?
  67. Date: 12 Apr 1994 19:46:30 GMT
  68. Organization: Augsburg College
  69.  
  70. Can any kind soul tell me if it is possible to have a background only
  71. application paste to the clipboard? 
  72.  
  73. The application is triggered by appleevents and I would like to have it
  74. place an image on the scrap before it returns. This works fine if I bring
  75. it to the front, but in the background it either completes without pasting
  76. anything, or crashes me into macsbug. 
  77.  
  78. I have looked at a lot of stuff but have not yet found anything that
  79. explicitly tells me that this can't be done with a background app. 
  80.  
  81. Perhaps a resumeevent posting to the event queue...
  82.  
  83. Any help would be greatly appreciated. 
  84. -- 
  85.  
  86. James West                             ***** I like Cacti... ****
  87. Augsburg College Graphic Center
  88. 731 21st Ave S
  89. Mpls. MN 55454        
  90. west@augsburg.edu                      ********  OUTCH!! ********
  91.  
  92. +++++++++++++++++++++++++++
  93.  
  94. >From Dave Falkenburg <falken@apple.com>
  95. Date: Wed, 13 Apr 1994 17:19:53 GMT
  96. Organization: Apple Computer, Inc.
  97.  
  98. In article <west-120494144037@141.224.192.172> James West,
  99. west@augsburg.edu writes:
  100. >Can any kind soul tell me if it is possible to have a background only
  101. >application paste to the clipboard? 
  102.  
  103. Nope. You don't want to know why...
  104.  
  105. A future rev of the scrap manager MAY provide a way to do this, but the
  106. current limitations on the scrap manager prevent it from working when
  107. called from the background.
  108.  
  109. -Dave Falkenburg
  110. -Apple Computer, Inc.
  111.  
  112. ---------------------------
  113.  
  114. >From DAVISM@kcgl1.eng.ohio-state.edu (Mike Davis, Chief of Operations -- KCGL)
  115. Subject: Determing selected-chosen printer
  116. Date: 5 Apr 1994 17:01:39 GMT
  117. Organization: The Ohio State University
  118.  
  119.  
  120.     I have checked a number of texts and also examined the STR resources
  121. for System, Chooser and a printer driver...  Where is the information stored
  122. as to which printer has been selected under the Chooser?  I know the name of
  123. the Printing Manager Resource File (PMRF) is stored in the System file in
  124. STR resource -8192, but I couldn't find anything which resembled the name of
  125. the actual chosen printer.
  126.  
  127.                             Thanks,
  128.                              Mike
  129. --
  130.  Internet: davism@KCGL1.eng.ohio-state.edu |
  131.             -or- DAVISM+@osu.edu           |   These Thoughts, They Be Mine
  132.    BITNET: DAVISM+@OHSTMAIL.BITNET         |
  133.  
  134. +++++++++++++++++++++++++++
  135.  
  136. >From Ben Rubinstein <benr@cogapp.demon.co.uk>
  137. Date: Tue, 5 Apr 1994 18:40:45 GMT
  138. Organization: Cognitive Applications, Brighton, England
  139.  
  140. In article <2ns5hj$fj8@charm.magnus.acs.ohio-state.edu> Mike Davis,
  141. DAVISM@kcgl1.eng.ohio-state.edu writes:
  142. >Where is the information stored as to which printer has been selected
  143. under
  144. >the Chooser?  I know the name of the Printing Manager Resource File
  145. (PMRF)
  146. >is stored in the System file in STR resource -8192...
  147.  
  148.  'STR ' resource ID -8192 in System has name of currently selected driver.
  149. 'PAPA' resource -8192 in the driver has name of current printer (pascal
  150. string at front
  151.     of resource).
  152.  
  153. I have an old XFCn to return the name of the current printer which works
  154. at least in our environment (networked LaserWriters) - can't guarantee
  155. how it will go with stylewriters, et al.  It has the following perhaps
  156. slightly worrying comment at the top:     "We cheat by just doing "PrOpen",
  157. hoping that this will ensure the current driver is open as a res file,
  158. and then looking for Papa (point is to avoid worrying about where the
  159. driver is in system 6/7)"
  160.  
  161. In fact, it's very short - so here it is:
  162. - --
  163. #define    PRNAMETYPE    'PAPA'
  164. #define    PRNAMEID    -8192
  165.  
  166.     PrOpen();
  167.     if (PrError() != noErr) { ....return error stuff...    }
  168.  
  169.     if (hRsrc = GetResource(PRNAMETYPE, PRNAMEID)) {
  170.         HLock(hRsrc);
  171.         paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) *(hRsrc));
  172.         HUnlock(hRsrc);
  173.         ReleaseResource(hRsrc);
  174.     } else {
  175.          ....return error stuff...
  176.     }
  177.  
  178.     PrClose();
  179. - ---
  180.  
  181. As I say, I make no warranties about it, but it's never given me
  182. trouble...
  183. Ben
  184.  
  185. +++++++++++++++++++++++++++
  186.  
  187. >From mgr@aggroup.aggroup.com (Mike Russell)
  188. Date: Tue, 05 Apr 1994 11:58:17 -0800
  189. Organization: the ag group, inc.
  190.  
  191. In article <2ns5hj$fj8@charm.magnus.acs.ohio-state.edu>,
  192. DAVISM@kcgl1.eng.ohio-state.edu (Mike Davis, Chief of Operations -- KCGL)
  193. wrote:
  194.  
  195. >     I have checked a number of texts and also examined the STR resources
  196. > for System, Chooser and a printer driver...  Where is the information stored
  197. > as to which printer has been selected under the Chooser?  I know the name of
  198.  
  199. It's in the PMRF in PAPA resource -8192 for LaserWriter and LaserWriter 8.
  200. This info is for use by the driver and is not stricly part of the
  201. interface.
  202.  
  203. +++++++++++++++++++++++++++
  204.  
  205. >From chewey@aol.com (Chewey)
  206. Date: 6 Apr 1994 09:46:04 -0400
  207. Organization: America Online, Inc. (1-800-827-6364)
  208.  
  209. For System 7.x the System resource file contains an'alis' resource (ID -8192)
  210. to the currently selected output device.  You can get this resource handle and
  211. use it in a call to ResolveAlias().  You'll get an FSSpec record to the actual
  212. output driver.
  213.  
  214. Hope this helps,
  215.  
  216. -Chewey
  217. - --------------
  218. Matthew E. Axsom
  219. Mac Software Engineer
  220. Mac/PC Connection, Inc.
  221. All opinions are mine, and not those of Mac/PC Connection, Inc. (bla, bla,
  222. bla).
  223.  
  224. +++++++++++++++++++++++++++
  225.  
  226. >From Manuel Veloso <veloso@netcom.com>
  227. Date: Wed, 6 Apr 1994 23:23:51 GMT
  228. Organization: Ibex Productions
  229.  
  230. In article <2ns5hj$fj8@charm.magnus.acs.ohio-state.edu> Mike Davis,
  231. DAVISM@kcgl1.eng.ohio-state.edu writes:
  232. >the Printing Manager Resource File (PMRF) is stored in the System file in
  233. >STR resource -8192, but I couldn't find anything which resembled the name of
  234. >the actual chosen printer.
  235.  
  236. Along with the rest of the info in the previous post, be warned that there's
  237. an alias to the currently selected printer driver resident in the system
  238. file (I think it's 'alis' 0). I'm not sure if it's still there, but it was
  239. in 7.0 (the last time I looked).
  240.  
  241. +++++++++++++++++++++++++++
  242.  
  243. >From dowdy@apple.com (Tom Dowdy)
  244. Date: Wed, 13 Apr 1994 23:45:09 GMT
  245. Organization: Apple Computer, Inc.
  246.  
  247. In article <netnewsCnv2Br.87L@netcom.com>, Manuel Veloso
  248. <veloso@netcom.com> wrote:
  249.  
  250. > In article <2ns5hj$fj8@charm.magnus.acs.ohio-state.edu> Mike Davis,
  251. > DAVISM@kcgl1.eng.ohio-state.edu writes:
  252. > >the Printing Manager Resource File (PMRF) is stored in the System file in
  253. > >STR resource -8192, but I couldn't find anything which resembled the name of
  254. > >the actual chosen printer.
  255. > Along with the rest of the info in the previous post, be warned that there's
  256. > an alias to the currently selected printer driver resident in the system
  257. > file (I think it's 'alis' 0). I'm not sure if it's still there, but it was
  258. > in 7.0 (the last time I looked).
  259.  
  260. Be warned that all of the above is undocumented and subject to change.
  261. If you rely on this information your application will break.  
  262.  
  263. But you may say, when will this breaking happen?  QuickDraw GX -- I
  264. *promise* that these methods of hacking around will *not* work.
  265.  
  266. -- 
  267.  Tom Dowdy                  Internet: dowdy@apple.COM
  268.  Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  269.  1 Infinite Loop            AppleLink: DOWDY1
  270.  Cupertino, CA 95014       
  271.  "The 'Ooh-Ah' Bird is so called because it lays square eggs."
  272.  
  273. ---------------------------
  274.  
  275. >From pcw@access1.digex.net (Peter Wayner)
  276. Subject: Drawing text vertically...
  277. Date: 5 Apr 1994 15:31:01 -0400
  278. Organization: Express Access Online Communications, Greenbelt, MD USA
  279.  
  280. I would like to draw text vertically. Does anyone have
  281. any code samples for how to do this? I'm presuming
  282. that I'll have to copy it and swap the x and y's.
  283. But does anyone have a definite "good" way to do it? 
  284.  
  285. Thanks a BNDL...
  286.  
  287. Peter Wayner
  288.  
  289.  
  290.  
  291. +++++++++++++++++++++++++++
  292.  
  293. >From ewies@athena.mit.edu (Evan Wies)
  294. Date: 10 Apr 1994 20:35:28 GMT
  295. Organization: Massachvsetts Institvte of Technology
  296.  
  297. In article <pcw.765574161@access1>
  298. pcw@access1.digex.net (Peter Wayner) writes:
  299.  
  300. > I would like to draw text vertically. Does anyone have
  301. > any code samples for how to do this? I'm presuming
  302. > that I'll have to copy it and swap the x and y's.
  303. > But does anyone have a definite "good" way to do it? 
  304. > Thanks a BNDL...
  305. > Peter Wayner
  306.  
  307. When you say "draw text vertically" do you mean like this:
  308. D
  309. E
  310. A
  311. T
  312. H
  313.  
  314. or do you mean that you want to display a string that is rotated 90
  315. degrees?
  316.  
  317. I have done the latter... I made a rotated-font with Fontographer and
  318. then wrote a routine that would display it. It doesn't look very pretty
  319. because fonts weren't designed to be displayed in that orientation; the
  320. spacing is irregular.  It fit my needs though...
  321.  
  322. I can give you the source and make a font for you, if that's what you
  323. need...
  324.  
  325. -Evan Wies
  326.  
  327. +++++++++++++++++++++++++++
  328.  
  329. >From dowdy@apple.com (Tom Dowdy)
  330. Date: Mon, 11 Apr 1994 17:56:37 GMT
  331. Organization: Apple Computer, Inc.
  332.  
  333. In article <pcw.765574161@access1>, pcw@access1.digex.net (Peter Wayner)
  334. wrote:
  335.  
  336. > I would like to draw text vertically. Does anyone have
  337. > any code samples for how to do this? I'm presuming
  338. > that I'll have to copy it and swap the x and y's.
  339. > But does anyone have a definite "good" way to do it? 
  340.  
  341. There are Snippets on the various developer CDs that show
  342. how to perform 90 degree rotation of bitmaps, which is
  343. basically what you need to do in order to draw rotated
  344. text.
  345.  
  346.  - OR -
  347.  
  348. Using QuickDraw GX:
  349.  myShape = GXNewText(3, "Hi!", nil);
  350.  GXRotateShape(myShape, ff(90), 0, 0);
  351.  GXDrawShape(myShape);
  352.  GXDisposeShape(myShape);
  353.  
  354. -- 
  355.  Tom Dowdy                  Internet: dowdy@apple.COM
  356.  Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  357.  1 Infinite Loop            AppleLink: DOWDY1
  358.  Cupertino, CA 95014       
  359.  "The 'Ooh-Ah' Bird is so called because it lays square eggs."
  360.  
  361. +++++++++++++++++++++++++++
  362.  
  363. >From opstad@apple.com (David Opstad)
  364. Date: 11 Apr 1994 16:12:36 -0700
  365. Organization: Apple Computer Inc, Cupertino, CA
  366.  
  367. In article <dowdy-110494105244@17.202.72.12>,
  368. Tom Dowdy <dowdy@apple.com> wrote:
  369. >
  370. >Using QuickDraw GX:
  371. > myShape = GXNewText(3, "Hi!", nil);
  372. > GXRotateShape(myShape, ff(90), 0, 0);
  373. > GXDrawShape(myShape);
  374. > GXDisposeShape(myShape);
  375.  
  376. Actually, Tom left out the other kind of vertical text. If you want the
  377. letters themselves to remain upright after the shape is rotated, add the
  378. following line before the GXDrawShape call:
  379.  
  380. GXSetShapeTextAttributes(myShape, GXGetShapeTextAttributes(myShape)
  381.   | gxVerticalText);
  382.  
  383. Dave Opstad
  384. GX Line Layout Weenie
  385.  
  386. +++++++++++++++++++++++++++
  387.  
  388. >From Philippe.Casgrain@univ-rennes1.fr (Philippe Casgrain)
  389. Date: Tue, 12 Apr 1994 15:47:31 +0100
  390. Organization: Universite de Rennes-1, Fac. de medecine dentaire
  391.  
  392.     For all the good folks that want to draw rotated text and do not have
  393. QuickDraw GX, may I suggest:
  394.  
  395. -r    34176 Oct  3 1992 ./mac/sc/snippets/imaging/graphics/rotatestring.hqx
  396.  
  397. on ftp.apple.com. It contains a (small) library and THINK Pascal/C source
  398. code. It worked great for me, the first time I tried it.
  399.  
  400. Philippe
  401.  
  402. -- 
  403. Philippe.Casgrain@univ-rennes1.fr
  404.     Mac Hacker Lite
  405.  
  406. +++++++++++++++++++++++++++
  407.  
  408. >From roderis@CSOS.ORST.EDU (Stephen Roderick)
  409. Date: 12 Apr 1994 15:30:00 GMT
  410. Organization: CS Outreach Services, Oregon State University, Corvallis, OR, USA
  411.  
  412. In article <dowdy-110494105244@17.202.72.12>,
  413. Tom Dowdy <dowdy@apple.com> wrote:
  414. >In article <pcw.765574161@access1>, pcw@access1.digex.net (Peter Wayner)
  415. >wrote:
  416. >
  417. >> I would like to draw text vertically. Does anyone have
  418. >> any code samples for how to do this? I'm presuming
  419. >
  420. >There are Snippets on the various developer CDs that show
  421. >how to perform 90 degree rotation of bitmaps, which is
  422. >basically what you need to do in order to draw rotated
  423. >text.
  424. >
  425. >-- 
  426. > Tom Dowdy                  Internet: dowdy@apple.COM
  427. > Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  428. > 1 Infinite Loop            AppleLink: DOWDY1
  429.  
  430. The Apple snippet is buggy. I have a working version which I can 
  431. send to anyone who wants it.
  432.  
  433. -- 
  434. - ---------------------------------------------------------
  435. Stephen Roderick
  436. roderis@kira.csos.orst.edu
  437. - ---------------------------------------------------------
  438.  
  439. +++++++++++++++++++++++++++
  440.  
  441. >From dowdy@apple.com (Tom Dowdy)
  442. Date: Tue, 12 Apr 1994 02:46:37 GMT
  443. Organization: Apple Computer, Inc.
  444.  
  445. In article <2oclh5$10a@apple.com>, opstad@apple.com (David Opstad) wrote:
  446.  
  447. > In article <dowdy-110494105244@17.202.72.12>,
  448. > Tom Dowdy <dowdy@apple.com> wrote:
  449. > >
  450. > >Using QuickDraw GX:
  451. > > myShape = GXNewText(3, "Hi!", nil);
  452. > > GXRotateShape(myShape, ff(90), 0, 0);
  453. > > GXDrawShape(myShape);
  454. > > GXDisposeShape(myShape);
  455. > Actually, Tom left out the other kind of vertical text. If you want the
  456. > letters themselves to remain upright after the shape is rotated, add the
  457. > following line before the GXDrawShape call:
  458. > GXSetShapeTextAttributes(myShape, GXGetShapeTextAttributes(myShape)
  459. >   | gxVerticalText);
  460.  
  461. Of course, but this isn't the kind of "rotated text" folks are always
  462. asking for. :-)
  463.  
  464. Dave also forgot to point out that this shape attribute will also
  465. work properly with languages that are normally vertical -- allowing
  466. you to mix roman and kanji text (as an example) and have the
  467. proper sections of the text adjust properly.
  468.  
  469. > Dave Opstad
  470. > GX Line Layout Weenie
  471.  
  472. And Dave is *really* supposed to be relaxing on his sabatical right
  473. now :-)
  474.  
  475. -- 
  476.  Tom Dowdy                  Internet: dowdy@apple.COM
  477.  Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  478.  1 Infinite Loop            AppleLink: DOWDY1
  479.  Cupertino, CA 95014       
  480.  "The 'Ooh-Ah' Bird is so called because it lays square eggs."
  481.  
  482. ---------------------------
  483.  
  484. >From ericg@cs.uoregon.edu (Mystery Man)
  485. Subject: HELP! Sending apple events
  486. Date: 12 Apr 1994 17:57:10 -0700
  487. Organization: University of Oregon Computer and Information Sciences Dept.
  488.  
  489. I need some help with getting the proper information for the AEAddressDesc 
  490. field in the AECreateAppleEvent procedure.  
  491.  
  492. What I would like to be able to do it select another application on another
  493. macintosh hooked up to the local network or an application on the MAC that my 
  494. program is running on.
  495.  
  496. >From what I understand, the PPCBrowser function will allow me to do this.
  497.  
  498. For some reason, I can't seem to give it the correct parameters.
  499.  
  500. Here is what I have tried:
  501.  
  502. (Everything compiles just fine, but myErr = -50 when I run this code)
  503.  
  504. I am certain that I am including all of the proper header files, etc..
  505.  
  506. I am running THINK C 6.01 on a IIsi.
  507.  
  508. void FindTheApplication( void )
  509. {
  510.     OSErr      myErr;
  511.     Str255     theNullString = "\p";
  512.     Str255    questionString = "\pPlease select the application";
  513.     
  514.     myErr = PPCBrowser( questionString,
  515.                 theNullString,
  516.                 FALSE,
  517.                 &(theTargetID.location),
  518.                 theLocation,
  519.                 nil,
  520.                 "\p" );
  521.                 
  522.     fprintf( cp, "The Error %d\n", myErr );
  523.  
  524. }
  525.  
  526. I would appreciate any and all help.  With this and the contortions I need to
  527. then go through to get this information into an AEAddressDesc type.
  528.  
  529. thanx..!
  530.  
  531.  
  532. ===Eric Gorr================ericg@cs.uoregon.edu===========aka MystryMan===
  533. _____ 
  534. |\ /| * Invincibility is in oneself, vulnerability is in the opponent
  535. | O | * Therefore the considerations of the intelligent always include both
  536. |/_\|   benefit and harm (Sun Tzu)
  537.  
  538. #include <standard.disclamer>
  539. =====Insults, like violence, are the last resort of the incompetent...=====
  540.  
  541.  
  542. +++++++++++++++++++++++++++
  543.  
  544. >From cassidy@esd55.enet.dec.com (Charlie Cassidy)
  545. Date: 13 Apr 1994 18:37:34 GMT
  546. Organization: Digital Equipment Corporation
  547.  
  548.  
  549. In article <2ofg16$c08@comix.cs.uoregon.edu>, ericg@cs.uoregon.edu (Mystery Man) writes:
  550. |>
  551. |>void FindTheApplication( void )
  552. |>{
  553. |>    OSErr      myErr;
  554. |>    Str255     theNullString = "\p";
  555. |>    Str255    questionString = "\pPlease select the application";
  556. |>    
  557. |>    myErr = PPCBrowser( questionString,
  558. |>                theNullString,
  559. |>                FALSE,
  560. |>                &(theTargetID.location),
  561. |>                theLocation,
  562. |>                nil,
  563. |>                "\p" );
  564. |>                
  565. |>    fprintf( cp, "The Error %d\n", myErr );
  566. |>
  567. |>}
  568. |>
  569. Eric,
  570.   The problem looks to be the theLocation parameter.  Pass the address
  571. &theLocation (unless of course it is already a pointer).
  572.  
  573. Here is a code snippet that illustrates the process from PPCBrowser to SendAE.
  574. It is translated from Pascal code that I pieced together from AboutThatMac.
  575.  
  576.  
  577. #include <EPPC.h>
  578. #include <PPCToolbox.h>
  579. #include <AppleEvents.h>
  580.  
  581. // define kMyAEClass and kMyAEID here
  582.  
  583. void main()
  584. {
  585.  
  586.       AppleEvent    theAE, theReply;
  587.     AEDescList    myAEDescList ;
  588.     AEAddressDesc    targetAddress ;
  589.     TargetID    toTargetID ;
  590.     PortInfoRec    myPortInfo ;
  591.     OSType         theParam;
  592.       Str255         gPrompt = "\pFoo";
  593.       Str255         gAppStr = "\pBar";
  594.       OSErr         theResult;
  595.   theResult = PPCBrowser(gPrompt, gAppStr, 0, &toTargetID.location, &myPortInfo,
  596.                nil, "\p");
  597.   toTargetID.name = myPortInfo.name;
  598.  
  599. // I cheated and hardcoded the size of toTargetID
  600.  
  601.   theResult = AECreateDesc(typeTargetID,  &toTargetID, 252,
  602.             &targetAddress);
  603.   theResult = AECreateAppleEvent(kMyAEClass, kMyAEID, &targetAddress,
  604.             kAutoGenerateReturnID, kAnyTransactionID,&theAE);
  605.   theResult = AECreateList(NULL, 0, 0, &myAEDescList);
  606.  
  607. // use AEPutPtr here to add parameters to the AEDescList  
  608.  
  609.   theResult = AEPutParamDesc(&theAE, keyDirectObject, &myAEDescList);
  610.   theResult = AEDisposeDesc(&myAEDescList);
  611. // another cheat, hardcoding the timeout value
  612.   theResult = AESend(&theAE, &theReply, kAEWaitReply + kAENeverInteract,
  613.            kAENormalPriority, 240, NULL, NULL);
  614.   theResult = AEDisposeDesc(&theAE);
  615.   theResult = AEDisposeDesc(&targetAddress);
  616. }
  617.  
  618.  
  619.  
  620. /* End. */
  621.  
  622. -- 
  623. =============================================================================
  624. "Good things can happen, and frequently do, to people as brainy and footsy
  625. as you." - Dr. Seuss
  626. =============================================================================
  627. Charlie Cassidy                        Internet: cassidy@elwood.enet.dec.com
  628. Digital Equipment Corporation          Amateur Radio: charlie@n1hlr.ampr.org
  629. SSD Engineering - SHR1-3/H28
  630. 333 South Street                       This posting reflects the opinion of 
  631. Shrewsbury, MA 01545                   the author, not Digital Equipment Corp
  632. =============================================================================
  633.  
  634. ---------------------------
  635.  
  636. >From louis@asterix.drev.dnd.ca (Louis Demers)
  637. Subject: How can I LOCK in a code segment ?
  638. Date: 7 Apr 1994 16:48:41 -0400
  639. Organization: Defence Research Establishment Valcartier
  640.  
  641. Hi,
  642.  
  643.     We are developping an application with MacApp 3.0.1,
  644. MPW C++. Part of the code uses functions pointers that
  645. are initialized at the beginning of the Application. Later
  646. when we use those function pointers, we crash because
  647. the code segment containing the function's code has been
  648. moved and the pointers are not pointing to the new location.
  649.  
  650.     What we would like to do is lock the proper code segment
  651. at the beginning so that our function pointers remain valid.
  652.  
  653.     This brings us to the more general consideration:
  654.  
  655.     " How can function pointers (in C) be reliably used in
  656.       an environment where code can be relocated without
  657.       notice ? "
  658.  
  659.       Thanks in advance...
  660.  
  661.  
  662.                 Louis
  663.  
  664. PS: The code really needs function pointers, we can't realistically
  665.     change the way this part of the code is written.
  666. -- 
  667. | Louis Demers              | DREV, Defence Research Establishment,Valcartier |
  668. | louis@asterix.drev.dnd.ca | POBox 8800, Courcelette,Quebec, CANADA, G0A 1R0 |
  669. |            (131.132.48.2) | Office: (418) 844-4424       fax (418) 844-4511 |
  670. +---------------------------+-------------------------------------------------+
  671.  
  672. +++++++++++++++++++++++++++
  673.  
  674. >From Willie Rauchwerger <willie-rauchwerger@uokhsc.edu>
  675. Date: 7 Apr 1994 22:43:25 GMT
  676. Organization: OU Health Sciences Center
  677.  
  678. In article <2o1rj9$4gb@asterix.drev.dnd.ca> Louis Demers,
  679. louis@asterix.drev.dnd.ca writes:
  680. >    " How can function pointers (in C) be reliably used in
  681. >      an environment where code can be relocated without
  682. >      notice ? "
  683.  
  684.  
  685. I would check your implementation of Function pointers. If I recall
  686. right (Check New Inside Macintosh: Memory or was that Volume 6),
  687. function pointers should remain valid throughout the execution time of
  688. your software.
  689.  
  690. If the segment is unloaded, I believe the jump table for the application
  691. correctly loads the segment so that your function pointer is valid.
  692.  
  693. I don't know if this is a correct explanation, but its behavior (ie you
  694. won't crash if a function pointer to a function in an unloaded segment) is
  695. true.
  696.  
  697. If this were not the case, people who have custom dialog filters, apple
  698. event handlers, etc. would crash like big dogs all over the place. And 
  699. that just doesn't happen.
  700.  
  701. - -----------------------------------------------------------------
  702. Willie Rauchwerger         AppleLink: Willie
  703. Telemedicine Software Guy  Internet:  willie-rauchwerger@uokhsc.edu
  704. OU Health Sciences Center
  705.  
  706. +++++++++++++++++++++++++++
  707.  
  708. >From pottier@dmi.ens.fr (Francois Pottier)
  709. Date: 8 Apr 1994 09:28:36 GMT
  710. Organization: Ecole Normale Superieure, PARIS, France
  711.  
  712. In article <2o22ad$r3l@romulus.ucs.uoknor.edu>, Willie Rauchwerger <willie-rauchwerger@uokhsc.edu> writes:
  713. |> In article <2o1rj9$4gb@asterix.drev.dnd.ca> Louis Demers,
  714. |> louis@asterix.drev.dnd.ca writes:
  715. |> >    " How can function pointers (in C) be reliably used in
  716. |> >      an environment where code can be relocated without
  717. |> >      notice ? "
  718. |> 
  719. |> 
  720. |> I would check your implementation of Function pointers. If I recall
  721. |> right (Check New Inside Macintosh: Memory or was that Volume 6),
  722. |> function pointers should remain valid throughout the execution time of
  723. |> your software.
  724.  
  725.  
  726. Well, you have two kinds of function pointers: pointers to functions
  727. that are actually inside your program and known to the compiler, and
  728. pointers to functions that have been loaded from code resources.
  729.  
  730. In the first case, when you use a pointer to a function inside your code,
  731. the compiler actually generates a reference to its *jump table entry*.
  732. The jump table entry contains a jump to the right address if the function
  733. is inside a loaded segment. Otherwise it contains a _LoadSeg instruction,
  734. which loads the segment first. So you needn't worry about loaded and
  735. unloaded segments.
  736.  
  737. In the second case, your code loads a stand-alone code resource. It is
  738. up to you to make sure that the resource doesn't move, otherwise your
  739. function pointer will become stale. But it's very easy: just after
  740. loading the resource, call HLock on it - it won't move any more, and
  741. you can use it.
  742.  
  743. Two small catches: beware of heap fragmentation. Having a locked resource
  744. right in the middle of your heap is a Bad Thing. Try to load resources
  745. early in the program flow.
  746. Also, if your program starts in 24-bit mode and switches to 32-bit mode
  747. later on, be sure to call StripAddress on your function pointers.
  748.  
  749. I guess that's it. If I made any mistakes, corrections are welcome.
  750.  
  751.  
  752. -- 
  753. Francois Pottier
  754. pottier@dmi.ens.fr
  755.  
  756. +++++++++++++++++++++++++++
  757.  
  758. >From c.reading@csi.compuserve.com (Charlie Reading)
  759. Date: 8 Apr 94 13:16:58 GMT
  760. Organization: CompuServe Incorporated
  761.  
  762. In article <2o1rj9$4gb@asterix.drev.dnd.ca> Louis Demers,
  763. louis@asterix.drev.dnd.ca writes:
  764. >    " How can function pointers (in C) be reliably used in
  765. >      an environment where code can be relocated without
  766. >      notice ? "
  767.  
  768. First of all, you have to make sure the function you are passing a
  769. pointer to is
  770. represented in the jump table (the jump table is non-relocatable, so the
  771. initial
  772. address never moves).  This can be accomplished by making it part of
  773. another
  774. segment (targets for inter-segment calls always show up in the jump
  775. table) or use
  776. a compiler switch which generates A5 relative addresses for function
  777. addresses).
  778. Appendix A in the MPW C++ Reference seems to indicate A5-relative
  779. addressing is
  780. the default, but if you are using "-b" or "-b2" it turns it around to
  781. PC-relative
  782. addressing.  If this is the case, use "-b3" instead.
  783.  
  784. Alternately, just what are you passing a pointer to?  Is it a "real" C
  785. function or
  786. is it a method?  If you are actually passing a pointer to a method to
  787. something that
  788. requires a pointer to a function it will probably blow big chunks (due to
  789. differences
  790. in calling conventions).
  791.  
  792. --
  793. Charlie Reading
  794. CompuServe Incorporated
  795. c.reading@csi.compuserve.com
  796. Any opinions expressed are not necessarily those of my employer.
  797.  
  798. +++++++++++++++++++++++++++
  799.  
  800. >From Ron_Hunsinger@bmug.org (Ron Hunsinger)
  801. Date: Sun, 10 Apr 94 21:15:48 PST
  802. Organization: Berkeley Macintosh Users Group
  803.  
  804. louis@asterix.drev.dnd.ca (Louis Demers) writes:
  805.  
  806. >We are developping an application with MacApp 3.0.1,
  807. >MPW C++. Part of the code uses functions pointers that
  808. >are initialized at the beginning of the Application. Later
  809. >when we use those function pointers, we crash because
  810. >the code segment containing the function's code has been
  811. >moved and the pointers are not pointing to the new location.
  812. >
  813. >What we would like to do is lock the proper code segment
  814. >at the beginning so that our function pointers remain valid.
  815. >
  816. >This brings us to the more general consideration:
  817. >
  818. >" How can function pointers (in C) be reliably used in
  819. >  an environment where code can be relocated without
  820. >  notice ? "
  821.  
  822. To answer your second question first: When you take the address of a
  823. procedure, the compiler can either take the address of the current
  824. position of the procedure in memory, or the address of the jump table
  825. entry for the procedure.  If the place where you are taking the address
  826. is in a different code segment than the procedure (an inter-segment
  827. reference), the compiler has no choice but to do the latter (take the
  828. address of the jump table entry).  If they are in the same segment
  829. (an intra-segment reference) the compiler can do it either way.
  830.  
  831. If there is any chance that the code segment might move, you need to
  832. make sure that you get the address of the jump table entry.  This
  833. entry will remain valid even if the segment moves, and even if the
  834. segment has been unloaded and removed from memory.
  835.  
  836. BTW: Code segments do not "move without notice".  You have to specifically
  837. unload them.  Although, in the case of MacApp, it may seem that way, 
  838. because MacApp will automatically unload all code segments that have
  839. not been marked resident each time through the event loop.  (In MacApp
  840. terminology, "resident" means "don't automatically unload".)
  841.  
  842. The only way you can be having problems is that:
  843.  
  844.   a) You are making an intra-segment reference, and
  845.   b) You are permitting the compiler to take the address of the
  846.      current position of the procedure (using a PC-relative address), and
  847.   c) Between the time you take the address, and the time you use it, the
  848.      segment is being unloaded (allowing it to move).
  849.  
  850. You can fix the problem by changing any of these three conditions:
  851.  
  852.   a) Force an inter-segment reference, by putting the initialization
  853.      routine that takes the address of the procedure into a different
  854.      code segment than the procedure itself (use #pragma segment), or
  855.   b) Tell the compiler to always use jump table addresses (set the -b3
  856.      compiler option, or do not set either -b or -b2), or
  857.   c) Never unload this code segment
  858.      c1) Put the target routine in one of the segments that MacApp is
  859.          already making resident (#pragma segment ARes), or
  860.      c2) Mark the segment resident at run time (call SetResidentSegment).
  861.  
  862. Method (a) is best - your initialization code should be in its own segment
  863. that will be unloaded after initialization anyway.  It is also the most
  864. portable.  All of the other methods have the disadvantage that they keep
  865. the initialization code in memory for the lifetime of the program, which
  866. is a waste of memory.
  867.  
  868. Method (b) could make the jump table bigger, as well as possibly confusing 
  869. MacApp, which assumes that intra-segment references are PC-relative.  I
  870. think this only matters in the debugger, and maybe not even there.  The
  871. larger jump table is the real problem - a MacApp program of any size can
  872. easily generate a jump table over 32K, which is bad news unless you set
  873. -model far.
  874.  
  875. Method (c2) would use a routine like:
  876.  
  877.   void MakeProcAddressSafe (void *fct) {
  878.       if (!GetSegNumber ((ProcPtr)fct)) {
  879.           // GetSegNumber will return zero if fct does not point into
  880.           // the jump table.  This is precisely the circumstance where
  881.           // we have to make sure the segment is resident.
  882.           SetResidentSegment (GetSegFromPC (fct), true); }
  883.       };
  884.  
  885. which you would call with something like:
  886.  
  887.    aProcAddress = SomeProcedure;
  888.    MakeProcAddressSafe (aProcAddress);
  889.  
  890. -Ron Hunsinger
  891.  
  892. +++++++++++++++++++++++++++
  893.  
  894. >From jwbaxter@olympus.net (John W. Baxter)
  895. Date: Tue, 12 Apr 1994 00:22:02 -0700
  896. Organization: Internet for the Olympic Peninsula
  897.  
  898. In article <001393BF.fc@bmug.org>, Ron_Hunsinger@bmug.org (Ron Hunsinger)
  899. wrote:
  900.  
  901. > louis@asterix.drev.dnd.ca (Louis Demers) writes:
  902. > >We are developping an application with MacApp 3.0.1,
  903. > >MPW C++. Part of the code uses functions pointers that
  904. > >are initialized at the beginning of the Application. Later
  905. > >when we use those function pointers, we crash because
  906. > >the code segment containing the function's code has been
  907. > >moved and the pointers are not pointing to the new location.
  908. > >
  909. > >What we would like to do is lock the proper code segment
  910. > >at the beginning so that our function pointers remain valid.
  911.  
  912. ...
  913.  
  914. > Method (c2) would use a routine like:
  915. >   void MakeProcAddressSafe (void *fct) {
  916. >       if (!GetSegNumber ((ProcPtr)fct)) {
  917. >           // GetSegNumber will return zero if fct does not point into
  918. >           // the jump table.  This is precisely the circumstance where
  919. >           // we have to make sure the segment is resident.
  920. >           SetResidentSegment (GetSegFromPC (fct), true); }
  921. >       };
  922. > which you would call with something like:
  923. >    aProcAddress = SomeProcedure;
  924. >    MakeProcAddressSafe (aProcAddress);
  925.  
  926.  
  927. Or...include the segment is a res! resource, and let InitUMemory () mark it
  928. resident for you.  That's how MacApp's own resident segments are so marked,
  929. and the expected method for application segments.
  930.  
  931. -- 
  932. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  933.    jwbaxter@pt.olympus.net
  934.  
  935. ---------------------------
  936.  
  937. >From John Hamilton Slye <jsbr+@andrew.cmu.edu>
  938. Subject: INIT vs. Background Only App.
  939. Date: Thu,  7 Apr 1994 23:49:45 -0400
  940. Organization: Junior, Electrical and Computer Engineering, Carnegie Mellon, Pittsburgh, PA
  941.  
  942.  
  943. I am writing a program which involves AppleTalk and I was eventually
  944. going to make it an INIT - would it be bad if I made it a
  945. background-only application that would be put in the Startup Items
  946. folder? Would that violate any programming guidelines?
  947.  
  948. I don't know much about writing INITs - if anyone can point me to a good
  949. step-by-step "how to write an INIT" guide somewhere I'd appreciate it.
  950.  
  951. It seems to me that it would be easier just to make my program a
  952. background-only application - though this would mean it could only run
  953. on machines with MultiFinder.
  954.  
  955. Any help on this would be much appreciated...thanks...
  956.  
  957.  
  958.  
  959.  
  960. =========================================================================
  961. J. Hamilton Slye (jsbr@andrew.cmu.edu) 1071 Morewood Ave., Pgh, Pa. 15213
  962.  
  963. "I know there are people in the world who do not love their fellow human
  964. beings...and I HATE people like that!"     -  Tom Lehrer
  965. =========================================================================
  966.  
  967.  
  968. +++++++++++++++++++++++++++
  969.  
  970. >From Scott_Gruby@hmc.edu (Scott Gruby)
  971. Date: 8 Apr 1994 04:18:05 GMT
  972. Organization: Harvey Mudd College, Claremont CA
  973.  
  974. In article <EhdBFNu00iV8ACoVE2@andrew.cmu.edu>, John Hamilton Slye
  975. <jsbr+@andrew.cmu.edu> wrote:
  976.  
  977. > I am writing a program which involves AppleTalk and I was eventually
  978. > going to make it an INIT - would it be bad if I made it a
  979. > background-only application that would be put in the Startup Items
  980. > folder? Would that violate any programming guidelines?
  981. > I don't know much about writing INITs - if anyone can point me to a good
  982. > step-by-step "how to write an INIT" guide somewhere I'd appreciate it.
  983. > It seems to me that it would be easier just to make my program a
  984. > background-only application - though this would mean it could only run
  985. > on machines with MultiFinder.
  986. > Any help on this would be much appreciated...thanks...
  987. > =========================================================================
  988. > J. Hamilton Slye (jsbr@andrew.cmu.edu) 1071 Morewood Ave., Pgh, Pa. 15213
  989. > "I know there are people in the world who do not love their fellow human
  990. > beings...and I HATE people like that!"     -  Tom Lehrer
  991. > =========================================================================
  992.  
  993. My personal opinion is that background-only applications (BOA) will cause
  994. less problems in the future, i.e. no INIT conflicts (or at least there
  995. shouldn't be any). It also looks like they are easier to write than INITs
  996. (I say looks because I have never written an INIT, only a BOA). Here's a
  997. neat thing you can do to BOAs and that is set the file type to 'appe' and
  998. put it in the extensions folder. It loads immediately after the Finder
  999. loads, but you can stick in some startup code that puts a startup icon.
  1000.  
  1001. As for supporting only machines that run MutliFinder, that is almost
  1002. becoming a non-problem. As programs get more and more complicated, running
  1003. anything on a machine not running Sys 7 is getting harder and harder.
  1004.  
  1005. There's some example BOA code on ftp.apple.com and also a tech note
  1006. explaining about BOAs. 
  1007.  
  1008. Good luck!
  1009.  
  1010. -- 
  1011. Scott Allen Gruby                         (Scott_Gruby@hmc.edu)
  1012. Macintosh Student System Manager
  1013. Academic Computing, Harvey Mudd College
  1014. Claremont, CA
  1015.          Finger ripem_public@eagle.st.hmc.edu for public key
  1016.  
  1017. +++++++++++++++++++++++++++
  1018.  
  1019. >From Aaron Wohl <aw0g+@andrew.cmu.edu>
  1020. Date: Fri,  8 Apr 1994 12:22:00 -0400
  1021. Organization: Systems Group 97, Carnegie Mellon, Pittsburgh, PA
  1022.  
  1023. I have written both inits and background only applications.   The
  1024. sources are available via anonymous ftp from akutaktak.andrew.cmu.edu
  1025. [128.2.35.1] in the /aw0g directory.
  1026.  
  1027. Softkiss is a driver/cdev/init to reprogram the SCC hardware to do
  1028. syncronous HDLC to control a ham radio.  Mailcheck is cdev/driver/init
  1029. to check your unix mail using UDP.
  1030.  
  1031. Finger server is faceless background task to implement the finger server
  1032. protocol for the macintosh.
  1033.  
  1034. A device driver installed by an init gives you a way for programs to
  1035. talk to your code once it is installed (they do a device driver call).  
  1036.  A faceless background task would be communicated over the network
  1037. (appletalk or UDP) if you needed to communicate with it.
  1038.  
  1039. Device drivers are harder to debug, run in the system heap (usually) and
  1040. if they leak memory usually leak system heap wich is worse than leaking
  1041. application heap.  Device drivers are an apropriate place for code that
  1042. needs to patch system calls.  Patches installed in applications only
  1043. affect that application and are switch with the application by
  1044. multifinder.
  1045. Aaron Wohl / ham callsign N3LIW / 412-731-3691 / 412-268-5032
  1046.  
  1047. +++++++++++++++++++++++++++
  1048.  
  1049. >From orch@aol.com (Orch)
  1050. Date: 12 Apr 1994 22:54:02 -0400
  1051. Organization: America Online, Inc. (1-800-827-6364)
  1052.  
  1053. A few years ago when System 7 was released at the Developers Conference,  Apple
  1054. was trying to convince developer to avoid writting INITs when ever possible,
  1055. and instead write background applications.
  1056.  
  1057.  
  1058. ---------------------------
  1059.  
  1060. >From awalters@leland.stanford.edu (Andrew J Walters)
  1061. Subject: Info on Graphics Animation Programming?
  1062. Date: 8 Apr 94 21:33:51 GMT
  1063. Organization: Stanford
  1064.  
  1065. I've been working on a board game where I want to move pieces around on
  1066. the
  1067. board.  I'm currently using simple offscreen quickdraw, but it is slow
  1068. and
  1069. not very smooth.  Where is a good source of information on animation
  1070. programming.
  1071.  
  1072.                     Thanks,
  1073.                     Andrew J Walters
  1074.  
  1075. +++++++++++++++++++++++++++
  1076.  
  1077. >From dwareing@apanix.apana.org.au (David Wareing)
  1078. Date: 11 Apr 94 10:59:24 GMT
  1079. Organization: Apanix Public Access Unix, +61 8 373 5485 (5 lines)
  1080.  
  1081. awalters@leland.stanford.edu (Andrew J Walters) writes:
  1082.  
  1083. >I've been working on a board game where I want to move pieces around on
  1084. >the
  1085. >board.  I'm currently using simple offscreen quickdraw, but it is slow
  1086. >and
  1087. >not very smooth.  Where is a good source of information on animation
  1088. >programming.
  1089.  
  1090. I could go into a whole list of arcane references for direct-to-screen
  1091. drawing, VBL tasks etc, but for your needs, I strongly suspect that
  1092. QuickDraw will do the job for you without you having to get your hands
  1093. *too* dirty.
  1094.  
  1095. Unless your board-games has a *lot* of moving sprites, or the sprites are
  1096. unusually large, it can more than likely be done well (very well actually)
  1097. with QuickDraw. These points and more, pop up all the time, but they are
  1098. always good to remember. They will speed up your animation like crazy:
  1099.  
  1100. *  Use GWorlds. Nice. Easy. No mucking around with bits.
  1101.  
  1102. *  Create your GWorlds with a call to NewGWorld. Pass it a screen depth of
  1103.    '0'. This will create an offscreen PixMap that is longword aligned to the
  1104.    screen. Pass the rect in global coords. Mucho speed increases here.
  1105.  
  1106. *  This is obvious, but move the least number of pixels as possible. Don't 
  1107.    always CopyBits unions of rects if not necessary. For example, don't 
  1108.    get the unionrect if the old and new sprite rects are not touching. 
  1109.    Some playing around and timing tests are needed here.
  1110.  
  1111. *  If you don't need special masking effects such as dissolves for your
  1112.    sprites, but you still have irregularly-shaped sprites (i.e. sprites
  1113.    that aren't rectangles), then *don't* use masks at all. Use the CopyBits
  1114.    transfer mode 'transparent' instead to cleanly compose sprites on top
  1115.    of backgrounds and other sprites. In my experience, CopyBits with 
  1116.    transparent, is faster than CopyBits with a maskRgn, and both are *much*
  1117.    faster than using CopyMask or CopyDeepMask. If you do need special
  1118.    masking effects (and remember, you can duplicate most effects offscreen
  1119.    by manipulating the pixmaps anyway), only use CopyBits, with a maskRgn.
  1120.  
  1121. *  Make sure that the source and destination pixmaps involved in a CopyBits
  1122.    have identical ColorTables. Otherwise, poor ole CopyBits has extra work
  1123.    to do. Old sagely advice says to "set the ctSeed field in the color
  1124.    tables of the source and destination to be the same..". Now I don't know
  1125.    if you really need to do this (haven't bothered to check personally,
  1126.    and Alex Metcalf says he noticed no noticeable speed improvements), when
  1127.    you have not changed the color tables at all. Left as an exerci... :)
  1128.  
  1129. *  Ensure that src and dest rects are the same size, else CopyBits has 
  1130.    expensive stretching to do.
  1131.  
  1132. *  Unless you want "masking" effects, only use a transfer mode of SrcCopy.
  1133.  
  1134. *  This one will upset some folks. Take over the machine. Rule the roost.
  1135.    At least for games. Games (and most other forms of animation) on the mac
  1136.    are a different breed of app altogether. Do *not* call WNE, not unless
  1137.    you want pathetic performance. If you must, call GNE or handle events
  1138.    some other way that is less expensive. What about that modem you've got
  1139.    buzzing away in the bgnd? Tough. A game is a game, and if its of the
  1140.    arcade variety, then you need all the speed you can get, without having
  1141.    to pander to other tasks. The game Deliverance sort of puts the lie to 
  1142.    this, as it handles bgnd tasks very well, while still maintaining very
  1143.    decent animation rates. But that's a one-off :)
  1144.  
  1145. *  Optimise your code a little more. I don't use SetRect, as I opt for 
  1146.    setting my rects by hand. Probably doesn't add much to the overall speed
  1147.    at the end of the day, but it makes me feel nice and snug to know that
  1148.    one less trap has been disposed of.
  1149.  
  1150. *  Don't colorise (or colorize if you are on the other side of the pond). 
  1151.    This means that you should make sure that the fg colour is black and the
  1152.    bg colour is white. Else, CopyBits has extra work to do again.
  1153.  
  1154.  
  1155. Most of these points (and many more) are described in detail in a very
  1156. handy tech note (get it at ftp.apple.com) called QD 21 "Time Space and
  1157. CopyBits" by Forrest Tanaka. Well worth the money :)
  1158.  
  1159. I use the book "Programming QuickDraw" by Surovell et al. Covers Sys 7,
  1160. all versions of QD to date, and despite its lousy index, meandering spirit
  1161. and occasionally buggy or incomplete examples, is a good buy, and covers a
  1162. lot of handy topics. (It also misses a few too...).
  1163.  
  1164. Develop has a whole range of articles and example code/apps. Don't know
  1165. the US price, but its easily the development bargain of the decade. 
  1166.   
  1167. Finally, there are several packages out there in ftp.land just waiting to
  1168. be picked up and used. SAT (Sprite Animation Toolkit) by Ingemar Ragnemalm
  1169. is a CopyBits replacement (and then some!), which would be highly suitable
  1170. for games development. Fast with good documentation and lots of examples.
  1171. Pascal and C from memory. 
  1172.  
  1173. Cellusoft Animation (or somesuch thing) is a shareware thingy available at
  1174. your friendly ftp site from Tony Small. This is bascially a CopyBits
  1175. animation tutorial, complete with working code, executables and docs.
  1176.  
  1177. SpriteWorld by Tony Myles is a comprehensive sprite animation package,
  1178. competing with SAT. Comes with code, executables, docs.
  1179.  
  1180. Happy blitting, and remember: CopyBits is certainly up to the job of many
  1181. games. It can handle your average boardgame with ease, and Pacman type
  1182. affairs shouldn't be a problem either.
  1183.  
  1184. --
  1185. David Wareing
  1186. Adelaide, South Australia
  1187. Mac Games & Multimedia Development        dwareing@apanix.apana.org.au
  1188. - --------------------------------------------------------------------
  1189.  
  1190. +++++++++++++++++++++++++++
  1191.  
  1192. >From al@crucible.powertools.com (Al Evans)
  1193. Date: 13 Apr 94 18:06:31 GMT
  1194. Organization: PowerTools, Austin, Texas
  1195.  
  1196. In article <dwareing.766061964@apanix.apana.org.au> dwareing@apanix.apana.org.au (David Wareing) writes:
  1197.  
  1198. >awalters@leland.stanford.edu (Andrew J Walters) writes:
  1199.  
  1200. >>I've been working on a board game where I want to move pieces around on
  1201. >>the
  1202. >>board.  I'm currently using simple offscreen quickdraw, but it is slow
  1203. >>and
  1204. >>not very smooth.  Where is a good source of information on animation
  1205. >>programming.
  1206.  
  1207. >   Old sagely advice says to "set the ctSeed field in the color
  1208. >   tables of the source and destination to be the same..". Now I don't know
  1209. >   if you really need to do this (haven't bothered to check personally,
  1210. >   and Alex Metcalf says he noticed no noticeable speed improvements), when
  1211. >   you have not changed the color tables at all. Left as an exerci... :)
  1212.  
  1213. As long as you're using the system color table for both source and
  1214. destination, which you are if you haven't changed it, there is no 
  1215. speed difference.
  1216.  
  1217. >Finally, there are several packages out there in ftp.land just waiting to
  1218. >be picked up and used. 
  1219.  
  1220. [SAT, Cellusoft Animation, SpriteWorld...]
  1221.  
  1222. You also might want to take a look at my own Graphic Elements, available
  1223. from mac.archive.umich.edu and mirror sites as:
  1224.  
  1225. /mac/misc/demo/graphicelementsdemo.sit.hqx
  1226.  
  1227. It offers performance comparable to that of SAT or SpriteWorld, with
  1228. a more "object-oriented" programming interface. It also has a few
  1229. "special features" -- for example, using horizontal and vertical
  1230. mirroring, you could get all four possible orientations of a game
  1231. piece out of the same graphic, which might be handy in a board game.
  1232.  
  1233.                     --Al Evans--
  1234. -- 
  1235. Al Evans            |   Graphic Elements: A new standard for 
  1236.                 |   high-performance interactive Macintosh graphics.
  1237. al@crucible.powertools.com  |   Available from mac.archive.umich.edu
  1238.                 |   /mac/misc/demo/graphicelementsdemo.sit.hqx
  1239.  
  1240. ---------------------------
  1241.  
  1242. >From Wilson Swee <ws8n+@andrew.cmu.edu>
  1243. Subject: Launching an application from a program...
  1244. Date: Tue, 12 Apr 1994 02:24:24 -0400
  1245. Organization: Senior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
  1246.  
  1247. Is it possible to launch an application from a program already running?
  1248. If so, what is a good way of handling it?
  1249.  
  1250. Wilson
  1251.  
  1252.  
  1253. +++++++++++++++++++++++++++
  1254.  
  1255. >From greer@utdallas.edu (Dale M. Greer)
  1256. Date: 12 Apr 1994 14:20:54 GMT
  1257. Organization: The University of Texas at Dallas
  1258.  
  1259. Wilson Swee (ws8n+@andrew.cmu.edu) wrote:
  1260. > Is it possible to launch an application from a program already running?
  1261. > If so, what is a good way of handling it?
  1262.  
  1263. > Wilson
  1264.  
  1265. Yes, and there is a very good example of this called AE Interaction
  1266. Sample of ftp.apple.com.  I don't remember the filepath for this, but
  1267. I think is was in the snippets directory under interapp.comm.  If 
  1268. you don't have access to ftp.apple.com, I could e-mail some stuff
  1269. to you.  The whole Sample is about 160K, but the FindAndLaunchApp
  1270. code is pretty small.
  1271.  
  1272. --
  1273.  
  1274. Dale Greer, greer@utdallas.edu
  1275. "You can't just wake up and kiss the mirror and say 'I'm so purdy,
  1276.  I think I'll run for Governor.'" - Texas Gov. Ann Richards
  1277.  
  1278. +++++++++++++++++++++++++++
  1279.  
  1280. >From tchan@irus.rri.uwo.ca (Thomas KC Chan)
  1281. Date: 13 Apr 1994 16:58:13 GMT
  1282. Organization: Robarts Research Institute, UWO, London, Ontario
  1283.  
  1284. And if you have the Think C on-line reference, there are enough
  1285. examples in implementing it;  the examples should be similar to those
  1286. given in "Inside MACintosh..." manuals.
  1287.  
  1288.  
  1289. Thomas Chan                       e-mail: tchan@irus.rri.uwo.ca
  1290.  
  1291. +++++++++++++++++++++++++++
  1292.  
  1293. >From nickt@tigger.demon.co.uk (nick thompson)
  1294. Date: Wed, 13 Apr 1994 21:14:42 GMT
  1295. Organization: Demon Internet
  1296.  
  1297. Someone asked for some app launching code.  Here are tow handy routines
  1298. - one for seeing if an app is running and one for launching an app.
  1299.  
  1300. You can use it like this:
  1301.  
  1302.     // if we are running we want the PSN and stuff,
  1303.     // otherwise we need to launch it and get the information
  1304.     
  1305.     if(!IsAppRunning( 'APPL',
  1306.                       'SiCk',
  1307.                       &targetPSN, 
  1308.                       &targetPIRec, 
  1309.                       targetName ) ) {
  1310.                       
  1311.         err = LaunchApp( 'SiCk' ) ;
  1312.   }
  1313.  
  1314. Nick
  1315.  
  1316.  
  1317. - -------------
  1318.  
  1319.  
  1320.  
  1321. // check to see using the process manager whether our 
  1322. // target app is running
  1323.  
  1324. Boolean IsAppRunning( OSType targetType,
  1325.                       OSType targetSignature,
  1326.                       ProcessSerialNumber *targetPSN, 
  1327.                       ProcessInfoRec *targetPIRec, 
  1328.                       StringPtr targetName )
  1329. {
  1330.     
  1331.     // we want to return the PSN if there is one
  1332.     // we want to return the Proc Info Rec if there is one
  1333.     // we will return true if we found our App
  1334.     // false if it wasn't running.
  1335.     
  1336.     // we need to loop through all the running processes and 
  1337.     // find one that looks like our background task.
  1338.     
  1339.     // This is all standard stuff - see IM Process Manager, page 2-6
  1340.     
  1341.     targetPSN->highLongOfPSN = 0 ;
  1342.     targetPSN->lowLongOfPSN = kNoProcess ;
  1343.     
  1344.     // set up the info record, for the call to get process info
  1345.     targetPIRec->processInfoLength = sizeof( ProcessInfoRec ) ;
  1346.     targetPIRec->processName = targetName ;    // the name will be put in
  1347. here
  1348.     targetPIRec->processAppSpec = nil ;        // we do not care about the
  1349. location of the app
  1350.     
  1351.     // right, loop through the running processes
  1352.     while( GetNextProcess( targetPSN ) == noErr ) {
  1353.     
  1354.         if( GetProcessInformation( targetPSN, targetPIRec ) == noErr ) {
  1355.             
  1356.             if( targetPIRec->processType == targetType 
  1357.                 && targetPIRec->processSignature == targetSignature )
  1358.                 
  1359.                 return true ;
  1360.         }
  1361.     }
  1362.     return false ;
  1363. }
  1364.  
  1365.  
  1366. // search in the desktop database for the app so that we can launch it
  1367. OSErr LaunchApp( OSType targetSignature)
  1368. {
  1369.     DTPBRec                theDatabase ;
  1370.     LaunchParamBlockRec    theLPB ;
  1371.     FSSpec                targetFSSpec ;
  1372.     OSErr                err ;
  1373.     
  1374.     theDatabase.ioCompletion = 0L ;
  1375.     theDatabase.ioNamePtr = 0L ;
  1376.     theDatabase.ioVRefNum = -1 ;    // restrict search to boot volume only
  1377.     
  1378.     if(( err = PBDTGetPath( &theDatabase )) != noErr )
  1379.         return err ;
  1380.         
  1381.     theDatabase.ioIndex = 0 ;
  1382.     theDatabase.ioFileCreator = targetSignature ;
  1383.     theDatabase.ioNamePtr = (StringPtr)targetFSSpec.name  ;
  1384.     
  1385.     if(( err = PBDTGetAPPL( &theDatabase, false )) != noErr)
  1386.         return err ;
  1387.         
  1388.     targetFSSpec.vRefNum     = theDatabase.ioVRefNum ;
  1389.     targetFSSpec.parID         = theDatabase.ioAPPLParID ;
  1390.     
  1391.     theLPB.launchBlockID     = extendedBlock ;
  1392.     theLPB.launchEPBLength     = extendedBlockLen ;
  1393.     theLPB.launchFileFlags     = 0 ;
  1394.     theLPB.launchControlFlags = launchContinue + launchNoFileFlags +
  1395. launchUseMinimum ;
  1396.     theLPB.launchAppSpec     = &targetFSSpec ;
  1397.     theLPB.launchAppParameters = 0L ;
  1398.     
  1399.     return( LaunchApplication( &theLPB ) ) ;
  1400. }
  1401.  
  1402. ---------------------------
  1403.  
  1404. >From craig@gpu.utcc.utoronto.ca (Craig Hubley)
  1405. Subject: Looking for a Windows-Mac portable GUI toolkit or builder
  1406. Date: Wed, 30 Mar 1994 11:45:16 GMT
  1407. Organization: UTCC Public Access
  1408.  
  1409. Would like to find a tool or toolkit that allows Windows and Mac
  1410. GUIs to be controlled from the same source code.  I am aware of
  1411. some tools (e.g. C++/Views, CommonView, XVT, etc.) but have not
  1412. heard from anyone who has used the latest versions to actually
  1413. build source-code-compatible systems.  Also I have heard that the
  1414. latest Borland C++ has classes that cover the difference completely.
  1415. Can anyone back this up ?  
  1416.  
  1417. Would be interested in particular in Smalltalk based tools.
  1418.  
  1419. Also in the running for a good portable flatfile database toolkit.
  1420.  
  1421. Important criteria for both are source code compatibility across
  1422. Windows and Mac, royalty free distribution of runtimes (product 
  1423. is for mass market), and ideally an object oriented binding in
  1424. C++ or Smalltalk.  I can live with C but will be talking to it
  1425. from C++ or Smalltalk in that case.
  1426.  
  1427. Thanks for any help you can offer
  1428.  
  1429. -- 
  1430.   Craig Hubley -- Consultants in object-oriented technology, languages,  --
  1431.   Craig Hubley & Associates -- user interface design, user productivity  --
  1432.   craig@utcc.Utoronto.CA    -- and financially responsive methodologies  --
  1433.   Seventy Eaton Avenue, Toronto, Ontario, Canada M4J 2Z5 -- 416-969-2826 --
  1434.  
  1435. +++++++++++++++++++++++++++
  1436.  
  1437. >From scharf@lrs.e-technik.uni-erlangen.de (Ron Scharf)
  1438. Date: Thu, 31 Mar 1994 13:24:16 +0200
  1439. Organization: LRS, University of Erlangen, Germany
  1440.  
  1441. craig@gpu.utcc.utoronto.ca (Craig Hubley) writes:
  1442.  
  1443. >Would like to find a tool or toolkit that allows Windows and Mac
  1444. >GUIs to be controlled from the same source code.  I am aware of
  1445. >some tools (e.g. C++/Views, CommonView, XVT, etc.) but have not
  1446. >heard from anyone who has used the latest versions to actually
  1447. >build source-code-compatible systems.
  1448.  
  1449. You might check Neuron Data's "Open Interface"; it's a GUI builder that
  1450. does not only allow system-independent interface creation (on Mac, Windows,
  1451. OpenLook, Motif and OS/2 Presentation Manager), but also allows you to
  1452. change the "look and feel" of your application at runtime to any of the
  1453. above listed - on any machine. So one can e. g. run an application on a Mac
  1454. and change - if he likes (?!) - the user interface to resemble that under
  1455. Windows. (Just telling what I've seen; no comments whether this will make
  1456. sense or not ;-). I've seen a demo where they used the same C source generated
  1457. by Open Interface to build GUIs for Macs, Windows and SUN OpenLook. Pretty
  1458. impressive. As far as I know, there are runtime libraries involved which you
  1459. have to buy; so you can't give an application away free of charge (although a
  1460. distribution license shall be rather cheap, as I've been told).
  1461. You can reach Neuron Data in the US at 156 University Ave., Palo Alto, CA 94301,
  1462. Phone 415-321-4488 Fax 415-321-3728.
  1463.  
  1464. Hopethishelps
  1465.     Ron
  1466.  
  1467. P.S. I'm in no way affiliated to Neuron Data or the like... Just saw a demo
  1468. of this (along with their expert system shell "Nexpert Object") some weeks ago.
  1469.  
  1470.  
  1471. -- 
  1472. Ron Scharf  --  scharf@lrs.e-technik.uni-erlangen.de  --  ron.scharf@msn.rmi.de
  1473. Institute of Computer Aided Circuit Design -- University of Erlangen -- Germany
  1474.        * PET2001 * SX-64 * Amiga1000 * Mac SE/30 * Newton MessagePad *
  1475.    "...this is not a love song, this isn't fantasy land..." - Rush, "Cold Fire"
  1476.  
  1477. +++++++++++++++++++++++++++
  1478.  
  1479. >From mxmora@unix.sri.com (Matt Mora)
  1480. Date: 31 Mar 1994 10:35:26 -0800
  1481. Organization: SRI International, Menlo Park, CA
  1482.  
  1483. In article <scharf.765112226@faulrs> scharf@lrs.e-technik.uni-erlangen.de (Ron Scharf) writes:
  1484.  
  1485. >above listed - on any machine. So one can e. g. run an application on a Mac
  1486. >and change - if he likes (?!) - the user interface to resemble that under
  1487. >Windows. (Just telling what I've seen; no comments whether this will make
  1488.  
  1489. You can do that for motif and windows but not mac. The mac interface is only
  1490. available on the mac.
  1491.  
  1492. >sense or not ;-). I've seen a demo where they used the same C source generated
  1493. >by Open Interface to build GUIs for Macs, Windows and SUN OpenLook. Pretty
  1494. >impressive. As far as I know, there are runtime libraries involved which you
  1495. >have to buy; so you can't give an application away free of charge (although a
  1496. >distribution license shall be rather cheap, as I've been told).
  1497.  
  1498.  
  1499. Actually, there are no runtime fees. So you can give it away to whomever.
  1500. As a developer you need to buy a developer "seat" which includes all the
  1501. things you need to create programs that run on your platform. You can also
  1502. buy "porting" kits for the platforms you want to deploy your program to.
  1503. Neuron recommends that you actually but a dev seat for each platform because
  1504. they price the porting kits almost as high as the development seats.
  1505.  
  1506.  
  1507. Xavier
  1508.  
  1509.  
  1510.  
  1511. -- 
  1512. ___________________________________________________________
  1513. Matthew Xavier Mora                       Matt_Mora@sri.com
  1514. SRI International                       mxmora@unix.sri.com
  1515. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  1516.  
  1517. +++++++++++++++++++++++++++
  1518.  
  1519. >From edandavi@well.sf.ca.us (Ed Allen and Avi Rappoport)
  1520. Date: 2 Apr 1994 23:55:33 GMT
  1521. Organization: The Whole Earth 'Lectronic Link, Sausalito, CA
  1522.  
  1523.  
  1524. I know a company that has actually used XVT for a shipping product.  Please
  1525. email me (attn: Avi) and I'll send you their name & phone number.
  1526.  
  1527. Avi Rappoport
  1528. - ------------
  1529. Using my own account, looking for a job (project management).
  1530.  
  1531. +++++++++++++++++++++++++++
  1532.  
  1533. >From ari@world.std.com (Ari I Halberstadt)
  1534. Date: Tue, 12 Apr 1994 16:09:35 GMT
  1535. Organization: The World Public Access UNIX, Brookline, MA
  1536.  
  1537. In article <scharf.765112226@faulrs>,
  1538. Ron Scharf <scharf@lrs.e-technik.uni-erlangen.de> wrote:
  1539. >craig@gpu.utcc.utoronto.ca (Craig Hubley) writes:
  1540. >
  1541. >>Would like to find a tool or toolkit that allows Windows and Mac
  1542. >>GUIs to be controlled from the same source code.  I am aware of
  1543. >>some tools (e.g. C++/Views, CommonView, XVT, etc.) but have not
  1544. >>heard from anyone who has used the latest versions to actually
  1545. >>build source-code-compatible systems.
  1546. >
  1547. >You might check Neuron Data's "Open Interface"; it's a GUI builder that
  1548.  
  1549. Try the book
  1550.  
  1551. Petrucci, Steve, "Cross-Platform Power Tools", Random House, 1993.
  1552. ISBN 0-679-79147-7. US$45.00.
  1553.  
  1554. The book describes many of the issues involved in developing a cross-
  1555. platform solution. A CD-ROM that contains a cross-platform library,
  1556. called "XPLIB", for Windows 3.1, Win32, and Macintosh is included. I
  1557. don't have a CD-ROM player, so I haven't been able to use XPLIB yet,
  1558. though you can swap the CD for floppies by writing to Random House
  1559. (I'd rather save my money and get a CD-ROM player). Licensing of XPLIB
  1560. for use in products is not really covered in the book, so I think
  1561. you'd have to contact the author to arrange for commercial use. Still,
  1562. $45 is pretty cheap for a cross-platform system. I also think it's a
  1563. good way for people who know Macintosh to get their feet wet in
  1564. Windows (and vice-versa).
  1565. -- 
  1566. Ari Halberstadt    ari@world.std.com     #include <std/disclaimer.h>
  1567. "These beetles were long considered to be very rare because very few
  1568. entomologists look for beetles in the mountains, in winter, at night,
  1569. during snow storms." -- Purves W. K., et al, "Life: The Science of
  1570.  
  1571. ---------------------------
  1572.  
  1573. >From Chris Hanson <chanson@mtlookitthat.chi.il.us>
  1574. Subject: PowerPC Anti-Aliased Text
  1575. Date: Sun, 10 Apr 94 12:22:02 -0600
  1576. Organization: Green Dragon Creations, Inc.
  1577.  
  1578.  
  1579. Here's an idea:
  1580.  
  1581. Now that PowerPC is out, many users have more processing power than they 
  1582. know what to do with.  (<= No flames please...)  Ergo we must find 
  1583. creative ways to burn all those cycles.  In reading Stewart Brand's "The 
  1584. Media Lab", I discovered the MIT research on anti-aliased text and how 
  1585. it's much easier to read etc.
  1586.  
  1587. SO... How hard would it be to implement a PowerPC extension that 
  1588. maintains an offscreen GWorld and patches QuickDraw's text-drawing 
  1589. routines?  It would  render the text at 2x or 4x actual size and then 
  1590. copy it to its intended destination at regular size with ditherCopy.  I 
  1591. figure a PowerPC should have enough CPU horsepower so this wouldn't 
  1592. noticeably degrade performance -- right?
  1593.  
  1594. Where would be the best place to patch this in?
  1595.  
  1596. TTFN,
  1597. Chris
  1598.  
  1599. +++++++++++++++++++++++++++
  1600.  
  1601. >From d88-jwa@mumrik.nada.kth.se (Jon W‰tte)
  1602. Date: 10 Apr 1994 19:34:20 GMT
  1603. Organization: The Royal Institute of Technology
  1604.  
  1605. In <94041012220221834@mtlookitthat.chi.il.us> Chris Hanson <chanson@mtlookitthat.chi.il.us> writes:
  1606.  
  1607. >Where would be the best place to patch this in?
  1608.  
  1609. Tail-patch OpenPort and OpenCPort to install their own text drawing
  1610. procs, which set the port to the offscreen port, fall throught to
  1611. the normal StdText, and then set the port back, CopyBits, and update
  1612. the pen location.
  1613. -- 
  1614.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  1615.  "Don't stick a Fork in your Eye."
  1616.  
  1617. +++++++++++++++++++++++++++
  1618.  
  1619. >From gdl@stlawrence.maths (Greg Landweber)
  1620. Date: 11 Apr 1994 00:22:11 GMT
  1621. Organization: (none)
  1622.  
  1623. In article <94041012220221834@mtlookitthat.chi.il.us> Chris Hanson <chanson@mtlookitthat.chi.il.us> writes:
  1624.    Now that PowerPC is out, many users have more processing power than they 
  1625.    know what to do with.  (<= No flames please...)  Ergo we must find 
  1626.    creative ways to burn all those cycles.  In reading Stewart Brand's "The 
  1627.    Media Lab", I discovered the MIT research on anti-aliased text and how 
  1628.    it's much easier to read etc.
  1629.  
  1630. Take a look at the latest version of Greg's Browser (just released to
  1631. sumex and umich).  It has an option to use anti-aliased text for its
  1632. main window font.  It's done in 680x0 code (and it isn't too slow if
  1633. you have a 68040), but it will be the first part that I port to
  1634. PowerPC native code (as soon as Metrowerks releases Code Warrior
  1635. DR/3 which I am told will generate the type of resources that I need).
  1636.  
  1637.    SO... How hard would it be to implement a PowerPC extension that 
  1638.    maintains an offscreen GWorld and patches QuickDraw's text-drawing 
  1639.    routines?  It would  render the text at 2x or 4x actual size and then 
  1640.    copy it to its intended destination at regular size with ditherCopy.  I 
  1641.    figure a PowerPC should have enough CPU horsepower so this wouldn't 
  1642.    noticeably degrade performance -- right?
  1643.  
  1644. I considered doing this a few months ago (when I first tried the
  1645. anti-aliasing code for Greg's Browser).  Unfortunately, this would be too
  1646. slow on a 680x0 Mac, and I'm not planning on buying a PowerMac until
  1647. I'm back in the USA in the fall.  It won't be hard to get the
  1648. anti-aliasing code wo1rking, but I'm not about to start debugging trap
  1649. patches without a machine to test on...
  1650.  
  1651. There was an article in Develop a while back explaining how to do
  1652. anti-aliasing.  If you want it to go at a good speed, you should write
  1653. your own ditherCopy-substitute, and I believe there was a follow-up
  1654. article in Develop describing that as well.
  1655.  
  1656.    Where would be the best place to patch this in?
  1657.  
  1658. Somewhere around the StdText routine.
  1659.  
  1660. -- Greg "Buttons"/"Browser" Landweber
  1661.    gdl@maths.ox.ac.uk
  1662.  
  1663. +++++++++++++++++++++++++++
  1664.  
  1665. >From cwiltgen@mcs.com (Charles Wiltgen)
  1666. Date: Sun, 10 Apr 1994 21:20:09 -0600
  1667. Organization: Waterman Design, Inc. (opinions are my own)
  1668.  
  1669. In article <94041012220221834@mtlookitthat.chi.il.us>, Chris Hanson
  1670. <chanson@mtlookitthat.chi.il.us> wrote:
  1671.  
  1672. > Here's an idea:
  1673.  
  1674. And a *great* one it is.
  1675.  
  1676. > Now that PowerPC is out, many users have more processing power than they 
  1677. > know what to do with.  (<= No flames please...)  Ergo we must find 
  1678. > creative ways to burn all those cycles.  In reading Stewart Brand's "The 
  1679. > Media Lab", I discovered the MIT research on anti-aliased text and how 
  1680. > it's much easier to read etc.
  1681.  
  1682. Absolutely.  Hopefully QuickDrawGX lets you do this more easily.
  1683.  
  1684. I was thinking that there may be some cases where you wouldn't want to
  1685. antialiased text, so a box with both application and font exceptions would
  1686. be nice.  Then you can specify that test in ThinkC shouldn't be
  1687. antialiased, and that you never want Chicago and Geneva (for example)
  1688. antialiased.
  1689.  
  1690. -- 
  1691. Charles Wiltgen    "Love is a snowmobile racing across the tundra and
  1692. cwiltgen@mcs.com    then suddenly it flips over, pinning you underneath.
  1693. (INTP)              At night, the ice weasels come." - Nietzsche (Groening)
  1694.  
  1695. +++++++++++++++++++++++++++
  1696.  
  1697. >From d88-jwa@hemul.nada.kth.se (Jon W‰tte)
  1698. Date: 11 Apr 1994 09:26:41 GMT
  1699. Organization: The Royal Institute of Technology
  1700.  
  1701. >> Media Lab", I discovered the MIT research on anti-aliased text and how 
  1702. >> it's much easier to read etc.
  1703.  
  1704. >Absolutely.  Hopefully QuickDrawGX lets you do this more easily.
  1705.  
  1706. Nope; QuickDraw GX is presently a one-color-only system.
  1707. No anti-aliasing yet :-(
  1708.  
  1709. -- 
  1710.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  1711.    This signature is kept shorter than 4 lines in the interests of UseNet
  1712.    S/N ratio.
  1713.  
  1714. +++++++++++++++++++++++++++
  1715.  
  1716. >From grstate@shade (Gavriel State)
  1717. Date: Tue, 12 Apr 1994 22:10:58 GMT
  1718. Organization: University of Waterloo
  1719.  
  1720. Chris Hanson (chanson@mtlookitthat.chi.il.us) wrote:
  1721.  
  1722. : Here's an idea:
  1723.  
  1724. : SO... How hard would it be to implement a PowerPC extension that 
  1725. : maintains an offscreen GWorld and patches QuickDraw's text-drawing 
  1726. : routines?  It would  render the text at 2x or 4x actual size and then 
  1727. : copy it to its intended destination at regular size with ditherCopy.  I 
  1728. : figure a PowerPC should have enough CPU horsepower so this wouldn't 
  1729. : noticeably degrade performance -- right?
  1730.  
  1731. Rather than doing it this way, it would be better to maintain a cached 
  1732. anti-aliased version of each font in a seperate GWorld.  This will make 
  1733. the actual drawing of any piece of text much faster since you won't be 
  1734. forced to do a ditherCopy every time you draw some text - instead you can 
  1735. use srcOr.  It'll be more work since you'll have to worry about the 
  1736. font metrics, etc, but if done correctly this doesn't have to be for 
  1737. PMacs only.  I think it would be plenty fast enough for '040 Macs....
  1738.  
  1739. You'd probably want to have some scheme to decide which fonts to cache
  1740. and when - otherwise you'll end up eating gobs and gobs of memory caching
  1741. fonts....but hey - the PowerMacs come with 8 Megs, so what does a few 
  1742. hundred K of cached fonts matter, right? ;-)  
  1743.  
  1744.  
  1745. --
  1746.   Gavriel State | 3B Systems Design Engineering/Economics | Univ. of Waterloo
  1747. Email: grstate@zeus.uwaterloo.ca|       "You can't 'not be' on a boat!"
  1748. - ------------------------------|       "I've often not been on boats."
  1749. (905) 669-5652 (in Toronto)     |"No, what you've been is often not on boats."
  1750. (519) 886-5765 (in Waterloo)    |    Rosencrantz and Guildenstern are Dead
  1751.  
  1752. +++++++++++++++++++++++++++
  1753.  
  1754. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1755. Date: Tue, 12 Apr 1994 21:49:47 GMT
  1756. Organization: Apple Computer
  1757.  
  1758. Chris Hanson, chanson@mtlookitthat.chi.il.us writes:
  1759. > SO... How hard would it be to implement a PowerPC extension that 
  1760. > maintains an offscreen GWorld and patches QuickDraw's text-drawing 
  1761. > routines?
  1762.  
  1763. It might be easier just to use a grayscale font. These are supported by Color
  1764. QuickDraw but there used to be bugs in rendering them in some circumstances.
  1765. (Don't know if these have ever been fixed.)
  1766.  
  1767. I've built some anti-aliased fonts (and you can play around with it in
  1768. PhotoShop or ColorIt.) In my opinion antialiased text works well at very
  1769. small sizes, say <9pt, because it is actually decipherable unlike b/w text;
  1770. and at large sizes, say >=24pt because it's prettier. In intermediate sizes
  1771. it just looks blurry and gives you a headache.
  1772.  
  1773. I think a lot of this could be improved if the hinting process knew about the
  1774. anti-aliasing, but that would require a lot of work inside the TrueType (or
  1775. ATM) renderer.
  1776.  
  1777. --Jens Alfke
  1778.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1779.             .apple.com              Rebel girl you are the queen of my world
  1780.  
  1781. +++++++++++++++++++++++++++
  1782.  
  1783. >From sho@bohr.physics.purdue.edu (Sho Kuwamoto)
  1784. Date: 13 Apr 94 15:43:58 GMT
  1785. Organization: Purdue University Physics Department
  1786.  
  1787. In article <Co62yB.IEB@watserv2.uwaterloo.ca> grstate@zeus.uwaterloo.ca writes:
  1788. >Rather than doing it this way, it would be better to maintain a cached 
  1789. >anti-aliased version of each font in a seperate GWorld.  This will make 
  1790. >the actual drawing of any piece of text much faster since you won't be 
  1791. >forced to do a ditherCopy every time you draw some text - instead you can 
  1792. >use srcOr.
  1793.  
  1794. This becomes a less practical solution if you want to do
  1795. sub-pixel level positioning.
  1796.  
  1797. -Sho
  1798. --
  1799. sho@physics.purdue.edu <<-- finger this account to find out what I'm
  1800.                             having for lunch!
  1801.  
  1802. <A HREF="http://physics.purdue.edu/~sho/homepage.html>Sho Kuwamoto</A>.
  1803.  
  1804. +++++++++++++++++++++++++++
  1805.  
  1806. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  1807. Date: 14 Apr 94 13:10:15 +1200
  1808. Organization: University of Waikato, Hamilton, New Zealand
  1809.  
  1810. In article <1994Apr12.214947.10961@gallant.apple.com>, Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  1811. >
  1812. > I've built some anti-aliased fonts (and you can play around with it in
  1813. > PhotoShop or ColorIt.) In my opinion antialiased text works well at very
  1814. > small sizes, say <9pt, because it is actually decipherable unlike b/w text;
  1815. > and at large sizes, say >=24pt because it's prettier. In intermediate sizes
  1816. > it just looks blurry and gives you a headache.
  1817. >
  1818. > I think a lot of this could be improved if the hinting process knew about the
  1819. > anti-aliasing, but that would require a lot of work inside the TrueType (or
  1820. > ATM) renderer.
  1821.  
  1822. In my partially-informed opinion, it's pointless to do both hinting and
  1823. anti-aliasing. Hinting is there to aid readability by removing irregularities
  1824. in the rendering of the text. Anti-aliasing is just there to smooth over the
  1825. irregularities; I don't believe it actually improves readability any.
  1826.  
  1827. Refutations (with evidence) welcomed...!
  1828.  
  1829. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1830. Info & Tech Services Division              fax: +64-7-838-4066
  1831. University of Waikato            electric mail: ldo@waikato.ac.nz
  1832. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1833.  
  1834. +++++++++++++++++++++++++++
  1835.  
  1836. >From dowdy@apple.com (Tom Dowdy)
  1837. Date: Thu, 14 Apr 1994 01:59:39 GMT
  1838. Organization: Apple Computer, Inc.
  1839.  
  1840. In article <1994Apr14.131015.27573@waikato.ac.nz>, ldo@waikato.ac.nz
  1841. (Lawrence D'Oliveiro, Waikato University) wrote:
  1842.  
  1843. > In article <1994Apr12.214947.10961@gallant.apple.com>, Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  1844. > >
  1845. > > I've built some anti-aliased fonts (and you can play around with it in
  1846. > > PhotoShop or ColorIt.) In my opinion antialiased text works well at very
  1847. > > small sizes, say <9pt, because it is actually decipherable unlike b/w text;
  1848. > > and at large sizes, say >=24pt because it's prettier. In intermediate sizes
  1849. > > it just looks blurry and gives you a headache.
  1850. > >
  1851. > > I think a lot of this could be improved if the hinting process knew about the
  1852. > > anti-aliasing, but that would require a lot of work inside the TrueType (or
  1853. > > ATM) renderer.
  1854. > In my partially-informed opinion, it's pointless to do both hinting and
  1855. > anti-aliasing. Hinting is there to aid readability by removing irregularities
  1856. > in the rendering of the text. 
  1857.  
  1858. Well, there are *some* things that are better done at a lower level.
  1859. One of the problems with the scale-to-4X and downsample to the
  1860. original size is that the font at 4X may actually look quite a bit
  1861. different than it normally does at (say), 12 point.  
  1862.  
  1863. There are better things that you can do if you know that the 4X scale
  1864. is "just pretend" and the only piece to know this is the scaler.
  1865.  
  1866. > Anti-aliasing is just there to smooth over the
  1867. > irregularities; I don't believe it actually improves readability any.
  1868. > Refutations (with evidence) welcomed...!
  1869.  
  1870. I'm sure you'll get lots of "does *too* work!" without evidence.
  1871. I've yet to see any real studies that show that anti-aliasing
  1872. improves readability.
  1873.  
  1874. *Lots* of people think that it looks better, and will claim things
  1875. such as "with systems that I've seen I can read text down to 4 point"...
  1876. I think probably the only practical use is in preparing slides,
  1877. where the results will be projected very large -- and that's the
  1878. difficult case, because you need to antialias against
  1879. the background area, which is typically a ramp-fill or something.
  1880.  
  1881. -- 
  1882.  Tom Dowdy                  Internet: dowdy@apple.COM
  1883.  Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  1884.  1 Infinite Loop            AppleLink: DOWDY1
  1885.  Cupertino, CA 95014       
  1886.  "The 'Ooh-Ah' Bird is so called because it lays square eggs."
  1887.  
  1888. +++++++++++++++++++++++++++
  1889.  
  1890. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1891. Date: Thu, 14 Apr 1994 22:50:19 GMT
  1892. Organization: Apple Computer
  1893.  
  1894. Lawrence D'Oliveiro, ldo@waikato.ac.nz writes:
  1895. > In my partially-informed opinion, it's pointless to do both hinting and
  1896. > anti-aliasing. Hinting is there to aid readability by removing
  1897. irregularities
  1898. > in the rendering of the text. Anti-aliasing is just there to smooth over the
  1899. > irregularities; I don't believe it actually improves readability any.
  1900.  
  1901. (a) Antialiasing greatly improves readability at small sizes. Proof: I can
  1902. read 4pt type if it's antialiased, but can't if it isn't. I do NOT believe it
  1903. improves readability at normal text (>=10pt) sizes.
  1904.  
  1905. (b) One of the problems with antialiasing by drawing the text at a larger
  1906. size and then shrinking it down is that the hinter lines features up with the
  1907. finer grid, but not necessarily with the final shrunk grid. This means that
  1908. edges and corners usually don't line up with exact pixels and you get gray
  1909. edges or little gray blobs sticking out. You can see this even with large
  1910. antialiased text. This is exactly the kind of problem that hinting is
  1911. designed to help with; the problem is that the hinting is using the finer
  1912. grid and not the coarser one. I believe that if the hinter used the coarse
  1913. grid but rendered to the finer one, the results would be a lot nicer. It
  1914. _might_ be possible to fix the instructions on a TrueType font to make it do
  1915. this...
  1916.  
  1917. --Jens Alfke (former type weenie)
  1918.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1919.             .apple.com              Rebel girl you are the queen of my world
  1920.  
  1921. +++++++++++++++++++++++++++
  1922.  
  1923. >From hall_j@sat.mot.com (Joseph Hall)
  1924. Date: Wed, 13 Apr 1994 02:41:47 GMT
  1925. Organization: Motorola Inc., Satellite Communications
  1926.  
  1927. Seems it was gdl@stlawrence.maths (Greg Landweber) who said:
  1928. >There was an article in Develop a while back explaining how to do
  1929. >anti-aliasing.  If you want it to go at a good speed, you should write
  1930. >your own ditherCopy-substitute, and I believe there was a follow-up
  1931. >article in Develop describing that as well.
  1932.  
  1933. Hmm.  I assume the article uses spatial filtering, but that isn't an 
  1934. optimal method for antialiasing objects in general.  You really need 
  1935. to have antialiasing built into the TrueType scan converter, and
  1936. then implement a transparency plane for color fonts.  Now, *that* would
  1937. be a patch you could be proud of!
  1938.  
  1939. -- 
  1940. Joseph Nathan Hall | Joseph's Law of Interface Design: Never give your users
  1941. Software Architect | a choice between the easy way and the right way.
  1942. Gorca Systems Inc. |                 joseph@joebloe.maple-shade.nj.us (home)
  1943. (on assignment)    | (602) 732-2549 (work)  Joseph_Hall-SC052C@email.mot.com
  1944.  
  1945. ---------------------------
  1946.  
  1947. >From Chris Roberts <ctr@pyrite.som.cwru.edu>
  1948. Subject: SubLaunching applications and DA's
  1949. Date: 8 Apr 1994 16:42:39 GMT
  1950. Organization: Case Western Reserve University
  1951.  
  1952. OK, one more time...   
  1953. I'm having a serious problem with some code I'm writing..  It is intended
  1954. to sublaunch applications...
  1955.  
  1956. Whenever I launch an application (via launch()) or a deskaccessory (via
  1957. OpenDeskAcc)
  1958. The application or DA doesn't launch...  
  1959.  
  1960. Instead, it waits until I switch applications, or quit...
  1961.  
  1962. I don't quite get what's wrong because I know I have made calls to
  1963. WaitNextEvent
  1964. after the call to launch or OpenDeskAcc..
  1965.  
  1966. Could there be something wrong with the way I'm calling WaitNextEvent?
  1967.  
  1968. I'm calling it like:
  1969.  
  1970. WaitNextEvent(everyEvent, &theEvent, 0xFFFFFFFF, NIL);
  1971.  
  1972. Is there something I should be doing differently?
  1973.  
  1974. Thanks, 
  1975.    Chris
  1976.  
  1977. +++++++++++++++++++++++++++
  1978.  
  1979. >From platypus@cirrus.som.cwru.edu (Gary Kacmarcik)
  1980. Date: 08 Apr 1994 18:44:04 GMT
  1981. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  1982.  
  1983.  
  1984. In article <2o41hv$7l0@usenet.INS.CWRU.Edu> Chris Roberts <ctr@pyrite.som.cwru.edu> writes:
  1985. >
  1986. > OK, one more time...   
  1987. > I'm having a serious problem with some code I'm writing..  It is intended
  1988. > to sublaunch applications...
  1989. >
  1990. > Whenever I launch an application (via launch()) or a deskaccessory (via
  1991. > OpenDeskAcc)
  1992. > The application or DA doesn't launch...  
  1993.  
  1994. it sounds like you're using the old interfaces.  have you tried using the
  1995. LaunchApplication and LaunchDeskAccessory routines described in 
  1996. IM: Processes?
  1997.  
  1998. these routines are working just dandy for me.
  1999.  
  2000. -gary j kacmarcik
  2001. platypus@cirrus.som.cwru.edu
  2002.  
  2003. +++++++++++++++++++++++++++
  2004.  
  2005. >From lrucker@parcplace.com (Lee Ann Rucker)
  2006. Date: 9 Apr 1994 00:08:30 GMT
  2007. Organization: ParcPlace
  2008.  
  2009. In article <PLATYPUS.94Apr8144404@cirrus.som.cwru.edu>,
  2010. platypus@cirrus.som.cwru.edu (Gary Kacmarcik) wrote:
  2011.  
  2012. > it sounds like you're using the old interfaces.  have you tried using the
  2013. > LaunchApplication and LaunchDeskAccessory routines described in 
  2014. > IM: Processes?
  2015. > these routines are working just dandy for me.
  2016.  
  2017. I'm using them in an MPW tool to run applications, but I'd like to be able
  2018. to specify a file for the app to open.  IM:Processes says that the
  2019. AppParameters struct can be used for sending an AppleEvent, but doesn't
  2020. explain how to set it up.  Could anyone provide sample code to do this?
  2021.  
  2022. Thanks
  2023.  
  2024. +++++++++++++++++++++++++++
  2025.  
  2026. >From platypus@cirrus.som.cwru.edu (Gary Kacmarcik)
  2027. Date: 09 Apr 1994 14:24:18 GMT
  2028. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  2029.  
  2030. In article <lrucker-080494160935@leeann-mac.parcplace.com> lrucker@parcplace.com (Lee Ann Rucker) writes:
  2031. >
  2032. > I'm using them in an MPW tool to run applications, but I'd like to be able
  2033. > to specify a file for the app to open.  IM:Processes says that the
  2034. > AppParameters struct can be used for sending an AppleEvent, but doesn't
  2035. > explain how to set it up.  Could anyone provide sample code to do this?
  2036.  
  2037. i haven't tried using the AppParameters struct.
  2038.  
  2039. why isn't it acceptable to send an 'odoc' event after the app is opened?
  2040.  
  2041.  
  2042. -gary j kacmarcik
  2043. platypus@cirrus.som.cwru.edu
  2044.  
  2045. +++++++++++++++++++++++++++
  2046.  
  2047. >From lrucker@parcplace.com (Lee Ann Rucker)
  2048. Date: 10 Apr 1994 19:35:57 GMT
  2049. Organization: ParcPlace
  2050.  
  2051. In article <PLATYPUS.94Apr9102418@cirrus.som.cwru.edu>,
  2052. platypus@cirrus.som.cwru.edu (Gary Kacmarcik) wrote:
  2053. | In article <lrucker-080494160935@leeann-mac.parcplace.com>
  2054. lrucker@parcplace.com (Lee Ann Rucker) writes:
  2055. | >
  2056. | > I'm using them in an MPW tool to run applications, but I'd like to be
  2057. able
  2058. | > to specify a file for the app to open.  IM:Processes says that the
  2059. | > AppParameters struct can be used for sending an AppleEvent, but doesn't
  2060. | > explain how to set it up.  Could anyone provide sample code to do this?
  2061. | i haven't tried using the AppParameters struct.
  2062. | why isn't it acceptable to send an 'odoc' event after the app is opened?
  2063. | -gary j kacmarcik
  2064. | platypus@cirrus.som.cwru.edu
  2065.  
  2066. Hadn't thought of that.  I'm not the one who wants to do it, actually - we
  2067. have customers who say "I can open an app with parameters with your Windows
  2068. product, how would I do the same thing on the Mac?"
  2069.  
  2070. I'm still curious about AppParameters, though.
  2071.  
  2072. +++++++++++++++++++++++++++
  2073.  
  2074. >From Deirdre Maloy <Deeny3@aol.com>
  2075. Date: Mon, 11 Apr 1994 20:26:38 GMT
  2076. Organization: Metro Information Services, Raleigh NC
  2077.  
  2078. The sample code is given in one of the CD-roms in the bowels somewhere.
  2079. I've modified it somewhat, but it's been working for over a year, so I
  2080. know it's solid.
  2081.  
  2082. extern    FInfo                    appFInfo;
  2083.  
  2084. extern    launchRecord            myLaunchInfo[MAX_SUBLAUNCHES];        //    info on where
  2085. app is located
  2086. extern    short                currentLaunch;
  2087.  
  2088. extern    Str255                myFile;
  2089.  
  2090. extern    AEDesc                myAddress,docDesc,launchDesc;
  2091. extern    AEDescList            theList;
  2092. extern    AliasHandle            withThis;
  2093. extern    AppleEvent            myAEvent;
  2094.  
  2095.  
  2096. void        addOpDocEvt(void)
  2097. {
  2098.         OSErr                myErr;
  2099.         ProcessSerialNumber    myPSN;
  2100.         
  2101.     GetCurrentProcess(&myPSN);
  2102.      myErr = AECreateDesc(typeProcessSerialNumber, (Ptr)&myPSN,
  2103. sizeof(ProcessSerialNumber), &myAddress);
  2104.  
  2105.     AECreateAppleEvent(kCoreEventClass,kAEOpenDocuments, &myAddress, -1, 0,
  2106. &myAEvent);
  2107.     
  2108.     AECreateList(0L, 0, FALSE, &theList);
  2109.     
  2110.     NewAlias(0L,&myLaunchInfo[currentLaunch].docName,&withThis);
  2111.     HLock((Handle)withThis);
  2112.  
  2113. AECreateDesc(typeAlias,(Ptr)*withThis,GetHandleSize((Handle)withThis),&
  2114. ocDesc);
  2115.     HUnlock((Handle)withThis);
  2116.     
  2117.     AEPutDesc(&theList,0,&docDesc);
  2118.     AEPutParamDesc(&myAEvent,keyDirectObject,&theList);
  2119.     
  2120.     AECoerceDesc(&myAEvent,typeAppParameters,&launchDesc);
  2121.     HLock((Handle)myAEvent.dataHandle);
  2122.     
  2123.     myLaunchInfo[currentLaunch].launchBlock.launchAppParameters =
  2124. (AppParametersPtr)*(launchDesc.dataHandle);
  2125.  
  2126. }
  2127.  
  2128.  
  2129.  
  2130. In article <lrucker-100494113729@leeann-mac.parcplace.com> Lee Ann
  2131. Rucker, lrucker@parcplace.com writes:
  2132. >| In article <lrucker-080494160935@leeann-mac.parcplace.com>
  2133. >lrucker@parcplace.com (Lee Ann Rucker) writes:
  2134. >| >
  2135. >| > I'm using them in an MPW tool to run applications, but I'd like to be
  2136. >able
  2137. >| > to specify a file for the app to open.  IM:Processes says that the
  2138. >| > AppParameters struct can be used for sending an AppleEvent, but
  2139. doesn't
  2140. >| > explain how to set it up.  Could anyone provide sample code to do
  2141. this?
  2142.  
  2143. +++++++++++++++++++++++++++
  2144.  
  2145. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  2146. Date: Wed, 13 Apr 1994 18:56:15 GMT
  2147. Organization: Apple Computer
  2148.  
  2149. Gary Kacmarcik, platypus@cirrus.som.cwru.edu writes:
  2150. > why isn't it acceptable to send an 'odoc' event after the app is opened?
  2151.  
  2152. Because then the app will get an 'oapp' followed by an 'odoc'. For most
  2153. document type apps this will cause a spurious untitled window to open; for
  2154. things like drop-boxes they may just quit immediately upon getting the 'oapp'.
  2155.  
  2156. Lee Ann, you might want to look at my SignatureToApp library, available on
  2157. the developer CD (or the 'develop' CD too, I think.) It's a C library that
  2158. lets you launch applications with documents. It includes a simple MPW tool
  2159. for launching apps; I don't remember if the tool accepts documents or not,
  2160. but it shouldn't be hard to extend it to do so.
  2161.  
  2162. --Jens Alfke
  2163.   jens_alfke@powertalk              Rebel girl, rebel girl,
  2164.             .apple.com              Rebel girl you are the queen of my world
  2165.  
  2166. ---------------------------
  2167.  
  2168. >From rjc@terminator.rs.itd.umich.edu (Robert John Churchill)
  2169. Subject: System 7 Menu on right side of menubar
  2170. Date: 4 Apr 1994 19:13:13 -0400
  2171. Organization: University of Michigan
  2172.  
  2173. I'm interested in putting up a menu on the right side of the
  2174. menubar, much like the Balloon help and Application menus.
  2175. Who knows how to do this?  (I saw this information posted a
  2176. while ago but didn't retain it.)  Thanks!
  2177.  
  2178. Robert
  2179. rjc@umich.edu
  2180.  
  2181.  
  2182. +++++++++++++++++++++++++++
  2183.  
  2184. >From gurgle@netcom.com (Pete Gontier)
  2185. Date: Wed, 6 Apr 1994 18:42:39 GMT
  2186. Organization: cellular
  2187.  
  2188. rjc@terminator.rs.itd.umich.edu (Robert John Churchill) writes:
  2189.  
  2190. >I'm interested in putting up a menu on the right side of the menubar,
  2191. >much like the Balloon help and Application menus. Who knows how to do
  2192. >this? (I saw this information posted a while ago but didn't retain it.)
  2193. >Thanks!
  2194.  
  2195. Eventually I will be releasing an API to do this. It's a lot less
  2196. trivial to do safely than you might think. There's a way to put an
  2197. icon suite in a menu title, and there's an ID range to use, and if you
  2198. really want your menu to behave like one of the system menus, you have
  2199. to insert your menu at the right time. All three of these things are
  2200. separate issues and all three rely on undocumented info. And that's why
  2201. I'll be releasing an API. Look for it soon in a theater near you.
  2202. -- 
  2203.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  2204.  
  2205. +++++++++++++++++++++++++++
  2206.  
  2207. >From Alexander M. Rosenberg <alexr@apple.com>
  2208. Date: Thu, 7 Apr 1994 01:28:38 GMT
  2209. Organization: Hackers Anonymous
  2210.  
  2211. In article <gurgleCnupB4.GEw@netcom.com> Pete Gontier, gurgle@netcom.com
  2212. writes:
  2213. > rjc@terminator.rs.itd.umich.edu (Robert John Churchill) writes:
  2214. > >I'm interested in putting up a menu on the right side of the menubar,
  2215. > >much like the Balloon help and Application menus. Who knows how to do
  2216. > >this? (I saw this information posted a while ago but didn't retain it.)
  2217. > >Thanks!
  2218. > Eventually I will be releasing an API to do this. It's a lot less
  2219. > trivial to do safely than you might think. There's a way to put an
  2220. > icon suite in a menu title, and there's an ID range to use, and if you
  2221. > really want your menu to behave like one of the system menus, you have
  2222. > to insert your menu at the right time. All three of these things are
  2223. > separate issues and all three rely on undocumented info. And that's why
  2224. > I'll be releasing an API. Look for it soon in a theater near you.
  2225.  
  2226. This menu ID range is reserved for use by Apple Computer, per page I-109 of
  2227. Inside Macintosh, Volume 1 and on page 1-47 of Inside Macintosh: More
  2228. Macintosh Toolbox. Both places specifically say "do not use."
  2229.  
  2230. So, how will your "API" serve to somehow magically make using undocumented
  2231. (and "do not use") things acceptable?
  2232. - -------------------------------------------------------------------------
  2233. -  Alexander M. Rosenberg  - INTERNET: alexr@apple.com      - Yoyodyne    -
  2234. -  330 Waverley St., Apt B - UUCP:ucbvax!apple!alexr        - Propulsion  -
  2235. -  Palo Alto, CA 94301     -                                - Systems     -
  2236. -  (415) 329-8463          - Nobody is my employer so       - :-)         -
  2237. -                          - nobody cares what I say.       -             -
  2238.  
  2239. +++++++++++++++++++++++++++
  2240.  
  2241. >From jbrowne@zaphod.ncsa.uiuc.edu (Jim Browne)
  2242. Date: 7 Apr 94 19:33:28 GMT
  2243. Organization: University of Illinois at Urbana
  2244.  
  2245. Alexander M. Rosenberg <alexr@apple.com> writes:
  2246.  
  2247. >So, how will your "API" serve to somehow magically make using undocumented
  2248. >(and "do not use") things acceptable?
  2249.  
  2250. I imagine the API will have checks of the system software version, etc. so it
  2251. can put up a big honkin' "This may not work with your system software, we
  2252. we're puds and used undocumented features.  Apple told us not to, but we
  2253. did it anyway." dialog if the proper hooks aren't available.
  2254.  
  2255. *or*
  2256.  
  2257. They could just get Microsoft to use it in all of their products.  Then Apple
  2258. engineers will do triple back flips to keep it working in the future.
  2259.  
  2260. (I wish people doing these undocumented whatevers would include a statement
  2261.  at the bottom of their posts stating "This will break in the future." so
  2262.  Apple people wouldn't have to spend thier time reminding us.)
  2263.  
  2264. -- 
  2265. Jim Browne                                             | jbrowne@ncsa.uiuc.edu |
  2266. Head NCSA Mac Telnet Hacker, SDG System Administrator  | (217) 244-7798        |
  2267. <a href="http://www.ncsa.uiuc.edu/SDG/People/jbrowne/jbrowne.html">Click me</a>
  2268.  "People can buy HANDGUNS easier." - S. Anichini, on accquiring IMSA yearbooks.
  2269.  
  2270. +++++++++++++++++++++++++++
  2271.  
  2272. >From gurgle@netcom.com (Pete Gontier)
  2273. Date: Fri, 8 Apr 1994 07:24:17 GMT
  2274. Organization: cellular
  2275.  
  2276. Alexander M. Rosenberg <alexr@apple.com> writes:
  2277.  
  2278. >This menu ID range is reserved for use by Apple Computer, per page
  2279. >I-109 of Inside Macintosh, Volume 1 and on page 1-47 of Inside
  2280. >Macintosh: More Macintosh Toolbox. Both places specifically say "do not
  2281. >use." So, how will your "API" serve to somehow magically make using
  2282. >undocumented (and "do not use") things acceptable?
  2283.  
  2284. It won't. It will, however, buy you a couple of other things:
  2285.  
  2286. 1) You won't have to reverse-engineer the information yourself.
  2287. 2) Presumably if it breaks I can fix it without your having to
  2288.    change your program.
  2289.  
  2290. It's not as if I'm going to claim in the documentation that the thing
  2291. is risk-free. However, it *is* better than having 17 people do it 17
  2292. different ways.
  2293.  
  2294. Now calm down. I give you permission to break it into itty bitty pieces
  2295. if you should be in a position to do so. Have fun.
  2296. -- 
  2297.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  2298.  
  2299. +++++++++++++++++++++++++++
  2300.  
  2301. >From Alexander M. Rosenberg <alexr@apple.com>
  2302. Date: Tue, 12 Apr 1994 10:39:58 GMT
  2303. Organization: Hackers Anonymous
  2304.  
  2305. In article <2nq6u9$ivm@terminator.rs.itd.umich.edu> Robert John Churchill,
  2306. rjc@terminator.rs.itd.umich.edu writes:
  2307. > I'm interested in putting up a menu on the right side of the
  2308. > menubar, much like the Balloon help and Application menus.
  2309. > Who knows how to do this?  (I saw this information posted a
  2310. > while ago but didn't retain it.)  Thanks!
  2311.  
  2312. You can't. Apple does not support the creation of "System Menus" by
  2313. third-party applications developers.
  2314.  
  2315. Re-read the "Toolbox Karma" technote if you have any questions.
  2316. - -------------------------------------------------------------------------
  2317. -  Alexander M. Rosenberg  - INTERNET: alexr@apple.com      - Yoyodyne    -
  2318. -  330 Waverley St., Apt B - UUCP:ucbvax!apple!alexr        - Propulsion  -
  2319. -  Palo Alto, CA 94301     -                                - Systems     -
  2320. -  (415) 329-8463          - Nobody is my employer so       - :-)         -
  2321. -                          - nobody cares what I say.       -             -
  2322.  
  2323. +++++++++++++++++++++++++++
  2324.  
  2325. >From zobkiw@datawatch.com (joe zobkiw)
  2326. Date: Wed, 13 Apr 1994 12:31:24 GMT
  2327. Organization: Datawatch Corporation
  2328.  
  2329. In article <1994Apr12.103958.979@gallant.apple.com>, Alexander M. Rosenberg
  2330. <alexr@apple.com> wrote:
  2331.  
  2332. > In article <2nq6u9$ivm@terminator.rs.itd.umich.edu> Robert John Churchill,
  2333. > rjc@terminator.rs.itd.umich.edu writes:
  2334. > > I'm interested in putting up a menu on the right side of the
  2335. > > menubar, much like the Balloon help and Application menus.
  2336. > > Who knows how to do this?  (I saw this information posted a
  2337. > > while ago but didn't retain it.)  Thanks!
  2338. > You can't. Apple does not support the creation of "System Menus" by
  2339. > third-party applications developers.
  2340.  
  2341. Apple might not support it...but...if you can get Microsoft to do it then
  2342. I'll betcha it'll never break in the future. :) There are numerous ways to
  2343. do this...but the important part of one way is...
  2344.  
  2345. - The menu IDs must be within a specific range. Start at -18321 and
  2346. increase (add to) this value until you find a blank space.
  2347. - IM-Text will show you how to put an icon as the title of the menu.
  2348. - Patch GetMenu, when it is called inserting the Balloon Help menu you can
  2349. insert your own menu first. Make sure you don't step on any other menu ids,
  2350. including the Balloon Help menu id.
  2351. - Patch MenuSelect to set up your menu items with the proper checkmarks,
  2352. disabled states, etc...
  2353. - Patch SystemMenu to get selections from your menu.
  2354.  
  2355. This works for a hack I wrote and has yet to break since 7.0. I also know
  2356. for a fact that this mechanism is used in numerous popular shareware and a
  2357. few commercial products.
  2358.  
  2359. ___________________________________________________________
  2360. _/_/_/_/   Joe Zobkiw                                   ,,,
  2361.     _/     Senior Software Engineer                     - -
  2362.   _/       Datawatch Corporation                         L
  2363. _/_/_/_/   zobkiw@datawatch.com                          -
  2364.  
  2365. ---------------------------
  2366.  
  2367. >From Joshua Joseph Marks <jmb1+@andrew.cmu.edu>
  2368. Subject: free vs. DisposPtr??
  2369. Date: Mon,  4 Apr 1994 01:48:44 -0400
  2370. Organization: Junior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
  2371.  
  2372. Being new to the mac game I'm still frustrated by the Mac included vs
  2373. ASCI ways of handling memory.  If I use NewPtr to allocate a given
  2374. structure, should I use DisposPtr to deallocate it?  Im using THINK C
  2375. 6.0 and when I use DisposPtr nothing seems to happen.  I call it:
  2376.  
  2377.     some_struct *my_struct;
  2378.  
  2379.     my_struct = (some_struct *) NewPtr (sizeof(some_struct));
  2380.     DisposPtr ((Ptr) my_struct);
  2381.  
  2382.     if I use the debugger and check out the value of *my_struct, what should I
  2383.     see?  Is this the right way to go about things?
  2384.  
  2385. +++++++++++++++++++++++++++
  2386.  
  2387. >From fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate)
  2388. Date: Mon, 4 Apr 1994 13:43:27 GMT
  2389. Organization: DCRT, NIH, Bethesda, MD
  2390.  
  2391. In article <Ehbucwm00WBNE7_2FN@andrew.cmu.edu>, Joshua Joseph Marks <jmb1+@andrew.cmu.edu> writes:
  2392. >
  2393. >Being new to the mac game I'm still frustrated by the Mac included vs
  2394. >ASCI ways of handling memory.  If I use NewPtr to allocate a given
  2395. >structure, should I use DisposPtr to deallocate it?  Im using THINK C
  2396. >6.0 and when I use DisposPtr nothing seems to happen.  I call it:
  2397. >
  2398. >    some_struct *my_struct;
  2399. >
  2400. >    my_struct = (some_struct *) NewPtr (sizeof(some_struct));
  2401. >    DisposPtr ((Ptr) my_struct);
  2402. >
  2403. >    if I use the debugger and check out the value of *my_struct, what should I
  2404. >    see?  Is this the right way to go about things?
  2405.  
  2406. You shouldn't see anything.  You haven't *changed* the block pointed to
  2407. by my_struct; you've just told the OS to consider that chunk of memory as
  2408. available.
  2409.  
  2410. NewPtr() is *exactly* like malloc(), and DisposePtr() is *exactly* like
  2411. free(), for most purposes.  Just as you must use free() to deallocate a
  2412. block obtained from malloc(), you must use DisposePtr() to deallocate a
  2413. block that you got via NewPtr().
  2414.  
  2415. In general, you oughtn't mix malloc() allocation with NewPtr() allocation;
  2416. they work differently (malloc() isn't part of the OS!), and so you can get
  2417. memory fragmentation problems if you mix them.  I personally never use
  2418. malloc(); if I have to port something large that uses it, I just use
  2419. #define malloc(x) NewPtr(x) to override it, or do a global search-and-
  2420. replace.
  2421.  
  2422. The actual mechanisms of how allocation is handled, as far as the programmer
  2423. is concerned, is just like the ANSI-defined library functions.
  2424.  
  2425. - -------------------------------------------------------------------
  2426. Christopher Tate             |   "Blue ice cubes?  How degenerate!"
  2427. MSD, Inc.                    |
  2428. fixer@faxcsl.dcrt.nih.gov    |    < anybody recognize the source? >
  2429.  
  2430. +++++++++++++++++++++++++++
  2431.  
  2432. >From scott.m.silver@dartmouth.edu (Scott M. Silver)
  2433. Date: 4 Apr 1994 15:08:21 GMT
  2434. Organization: Dartmouth College - Hanover, NH
  2435.  
  2436. In article <1994Apr4.134327.2777@alw.nih.gov>
  2437. fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate) writes:
  2438.  
  2439. > In general, you oughtn't mix malloc() allocation with NewPtr() allocation;
  2440. > they work differently (malloc() isn't part of the OS!), and so you can get
  2441. > memory fragmentation problems if you mix them.  I personally never use
  2442. > malloc(); if I have to port something large that uses it, I just use
  2443. > #define malloc(x) NewPtr(x) to override it, or do a global search-and-
  2444. > replace.
  2445.  
  2446. Be very careful not to use a NewPtr() call and then use a free() to
  2447. dispose it.  Like Chris said, malloc is considered a private
  2448. implementation, and free is simply its complement.  Although you still
  2449. can get memory fragmentation problems when using either NewPtr or
  2450. malloc.
  2451.  
  2452. To summarize:
  2453. NewPtr begat DisposePtr
  2454. malloc begat free
  2455.  
  2456. Scott
  2457. ____________________________________________________________________
  2458. Scott Silver            Dartmouth College                Hanover, NH
  2459.  
  2460. +++++++++++++++++++++++++++
  2461.  
  2462. >From dsquirre@reed.edu (Douglas Squirrel)
  2463. Date: 5 Apr 1994 08:39:08 GMT
  2464. Organization: Reed College,  Portland, Oregon
  2465.  
  2466. >NewPtr() is *exactly* like malloc(), and DisposePtr() is *exactly* like
  2467. >free(), for most purposes.
  2468.  
  2469. 1. How *does* NewPtr() work?  Does it just do a NewHandle() and then HLock()
  2470.     it, and if so, doesn't this cause heap problems?
  2471.  
  2472. 2. When is NewPtr() *not* exactly like malloc()?
  2473.  
  2474. I don't pretend to understand memory management on the Mac, so non-technical
  2475. replies would be appreciated.
  2476.  
  2477. --dsquirre@reed.edu
  2478.  
  2479. +++++++++++++++++++++++++++
  2480.  
  2481. >From fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate)
  2482. Date: Tue, 5 Apr 1994 13:28:10 GMT
  2483. Organization: DCRT, NIH, Bethesda, MD
  2484.  
  2485. In article <2nr83c$3cc@scratchy.reed.edu>, dsquirre@reed.edu (Douglas Squirrel) writes:
  2486. > Chris Tate wrote:
  2487. >
  2488. >> NewPtr() is *exactly* like malloc(), and DisposePtr() is *exactly* like
  2489. >> free(), for most purposes.
  2490. >
  2491. >1. How *does* NewPtr() work?  Does it just do a NewHandle() and then HLock()
  2492. >    it, and if so, doesn't this cause heap problems?
  2493. >
  2494. >2. When is NewPtr() *not* exactly like malloc()?
  2495.  
  2496. NewPtr() is the native OS routine for allocating a block of memory.  It
  2497. finds a block of the appropriate size, marks it internally as being
  2498. "allocated," and returns a pointer to it for the program to use.  It
  2499. doesn't go through NewHandle().
  2500.  
  2501. malloc() and NewPtr() are different in that NewPtr() directly calls the OS's
  2502. memory management.  In particular, the OS keeps track of what parts of
  2503. memory are allocated or not.  malloc(), on the other hand, is a library
  2504. routine.  This means that the compiler writers created their own set of
  2505. routines for determining what memory is to be considered "allocated" or
  2506. not.
  2507.  
  2508. In its simplest form, malloc() could simply call NewPtr() directly, and
  2509. that would be that.  However, under many implementations of the C libraries,
  2510. malloc() works differently.  Under THINK C, for example, malloc() allocates
  2511. "chunks" much larger than your requested allocation, and manages "sub-blocks"
  2512. within those chunks itself.  So, if you malloc() three smallish objects,
  2513. you might actually find yourself with three pointers, all of which point
  2514. somewhere inside a single "chunk" that the malloc() library obtained from
  2515. the OS by calling NewPtr().
  2516.  
  2517. Practically speaking, the major issue that differs between using NewPtr()
  2518. and using malloc() is that with some compilers, when you use malloc(),
  2519. you can never actually reclaim *all* of the space you allocate.  The
  2520. library may not give the "chunks" back to the OS.  You can still malloc()
  2521. memory out of them (since the malloc() library still knows about them),
  2522. but the rest of the OS will never be able to access that memory.
  2523.  
  2524. Sometimes malloc() can be better; in particular, this "chunk"-based
  2525. mechanism, in which malloc() does its own free-block tracking, can be
  2526. rather faster than NewPtr().  But, as I said, it does have its drawbacks
  2527. as well.
  2528.  
  2529. - -------------------------------------------------------------------
  2530. Christopher Tate             |   "Blue ice cubes?  How degenerate!"
  2531. MSD, Inc.                    |
  2532. fixer@faxcsl.dcrt.nih.gov    |    < anybody recognize the source? >
  2533.  
  2534. +++++++++++++++++++++++++++
  2535.  
  2536. >From jwbaxter@olympus.net (John W. Baxter)
  2537. Date: Tue, 05 Apr 1994 08:25:59 -0700
  2538. Organization: Internet for the Olympic Peninsula
  2539.  
  2540. In article <2nr83c$3cc@scratchy.reed.edu>, dsquirre@reed.edu (Douglas
  2541. Squirrel) wrote:
  2542.  
  2543. > 1. How *does* NewPtr() work?  Does it just do a NewHandle() and then HLock()
  2544. >     it, and if so, doesn't this cause heap problems?
  2545.  
  2546. No...NewPtr () works quite hard to position the newly-allocated block as
  2547. low in the heap as possible, shoving relocatable blocks upwards to
  2548. accomplish that.  [You should have as few locked handles in arbitrary
  2549. locations about the heap as possible before calling NewPtr (), or proper
  2550. placement of the new non-relocatable block may not be possible.]
  2551.  
  2552. If the block you allocate is never going to move, use NewPtr ().  If it's
  2553. going to be relocatable but locked for longish periods, it's best (but not
  2554. ideal) to move it high on the heap before locking it.  Other locks should
  2555. be left in place for the shortest rational periods you can.
  2556.  
  2557. The above is all well described in Inside Macintosh:  Memory.  The
  2558. relationship with malloc () and free () isn't, since that's up to the
  2559. compiler implementors, who should do an equally good job of describing
  2560. their implementation.
  2561.  
  2562. -- 
  2563. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  2564.    jwbaxter@pt.olympus.net
  2565.  
  2566. +++++++++++++++++++++++++++
  2567.  
  2568. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  2569. Date: Thu, 7 Apr 1994 19:24:26 GMT
  2570. Organization: Apple Computer
  2571.  
  2572. fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate) writes:
  2573. > In general, you oughtn't mix malloc() allocation with NewPtr() allocation;
  2574. > they work differently (malloc() isn't part of the OS!), and so you can get
  2575. > memory fragmentation problems if you mix them.  I personally never use
  2576. > malloc(); if I have to port something large that uses it, I just use
  2577. > #define malloc(x) NewPtr(x) to override it, or do a global search-and-
  2578. > replace.
  2579.  
  2580. BAD idea! All the Mac implementations of malloc that I've seen are much more
  2581. efficient than NewPtr, in that they usually don't make trap calls or move
  2582. memory. (They get memory from NewPtr in large chunks and then parcel out that
  2583. memory bit by bit on every malloc call.) Their algorithms are also simpler
  2584. and faster because they don't have to deal with relocatable blocks.
  2585.  
  2586. Malloc also reduces heap fragmentation in that memory returned by free is
  2587. kept inside a Mac memory manager block until it's re-used by malloc, so the
  2588. MM doesn't try anything dumb like allocating a handle inside the unused space.
  2589.  
  2590. If you have stuff with both malloc and NewPtr calls I'd suggest replacing
  2591. NewPtr with malloc, not the other way 'round.
  2592.  
  2593. --Jens Alfke
  2594.   jens_alfke@powertalk              Rebel girl, rebel girl,
  2595.             .apple.com              Rebel girl you are the queen of my world
  2596.  
  2597. +++++++++++++++++++++++++++
  2598.  
  2599. >From fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate)
  2600. Date: Fri, 8 Apr 1994 11:50:19 GMT
  2601. Organization: DCRT, NIH, Bethesda, MD
  2602.  
  2603. In article <1994Apr7.192426.5155@gallant.apple.com>, Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  2604. >fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate) writes:
  2605. >> In general, you oughtn't mix malloc() allocation with NewPtr() allocation;
  2606. >> they work differently (malloc() isn't part of the OS!), and so you can get
  2607. >> memory fragmentation problems if you mix them.  I personally never use
  2608. >> malloc(); if I have to port something large that uses it, I just use
  2609. >> #define malloc(x) NewPtr(x) to override it, or do a global search-and-
  2610. >> replace.
  2611. >
  2612. >BAD idea! All the Mac implementations of malloc that I've seen are much more
  2613. >efficient than NewPtr, in that they usually don't make trap calls or move
  2614. >memory. (They get memory from NewPtr in large chunks and then parcel out that
  2615. >memory bit by bit on every malloc call.) Their algorithms are also simpler
  2616. >and faster because they don't have to deal with relocatable blocks.
  2617.  
  2618. Except that you can *never* recover memory allocated via malloc(), at least
  2619. under THINK C.  It's permanently part of the malloc() pool.  Also, malloc()
  2620. won't allocate pools of more than a certain size, and so anything bigger
  2621. than that will be allocated via a native NewPtr() call.  Fragmentation
  2622. in this case is just like using NewPtr() exclusively - actually worse,
  2623. since the permanent malloc() pools get in the way.
  2624.  
  2625. I would probably recommend thus:  if most of the memory allocation 
  2626. you do is via malloc() (i.e. is not done for use by the OS), then it's
  2627. probably better to go ahead and use the library malloc() function.
  2628. However, if you need to allocate OS-style memory in large part as well,
  2629. you will probably make fragmentation worse by using malloc() instead
  2630. of only NewPtr().
  2631.  
  2632. Offhand, I can think of a couple of ways to improve the library malloc().
  2633. One is to deallocate empty pools (which would avoid the problem of having
  2634. residual blocks permanently mucking up the heap).  Another might be to
  2635. have the pools allocated as *handles*, and locked whenever there is an
  2636. allocated sub-block.  When the last sub-block in the pool is free()'d,
  2637. unlock the pool handle and let it float until another allocation is
  2638. needed (then maybe move it high?  all sorts of possibilities here...).
  2639.  
  2640. - -------------------------------------------------------------------
  2641. Christopher Tate             |   "Blue ice cubes?  How degenerate!"
  2642. MSD, Inc.                    |
  2643. fixer@faxcsl.dcrt.nih.gov    |    < anybody recognize the source? >
  2644.  
  2645. +++++++++++++++++++++++++++
  2646.  
  2647. >From dsquirre@reed.edu (Douglas Squirrel)
  2648. Date: 9 Apr 1994 09:52:19 GMT
  2649. Organization: Reed College,  Portland, Oregon
  2650.  
  2651. I tried changing all my mallocs to NewPtrs and frees to DisposPtrs.
  2652.  
  2653. And my application runs ten times slower!!!
  2654.  
  2655. It is a fairly simple text viewer, with the text represented as a linked list 
  2656. of lines terminated by newlines.  So it dynamically allocates space for each
  2657. line as it reads it from the disk.
  2658.  
  2659. Why did this happen?
  2660. --dsquirre@reed.edu
  2661.  
  2662. +++++++++++++++++++++++++++
  2663.  
  2664. >From Reid Ellis <rae@alias.com>
  2665. Date: Wed, 13 Apr 1994 04:04:26 GMT
  2666. Organization: Alias Research, Inc., Toronto ON Canada
  2667.  
  2668. Douglas Squirrel <dsquirre@reed.edu> writes:
  2669. |I tried changing all my mallocs to NewPtrs and frees to DisposPtrs.
  2670. |
  2671. |And my application runs ten times slower!!!
  2672. [...]
  2673. |Why did this happen?
  2674.  
  2675. Because malloc() and free() were optimizing memory allocation for you.
  2676. NewPtr() and DisposPtr() are notoriously slow [on 68k Macintoshes].
  2677. This is one reason there is a "Modern Memory Manager" on the
  2678. PowerPC's.
  2679.  
  2680. Reid
  2681. --
  2682. - -
  2683. Reid Ellis, Alias Research Inc.
  2684. +1 416 362 9181 <rae@Alias.com>
  2685.  
  2686. ---------------------------
  2687.  
  2688. End of C.S.M.P. Digest
  2689. **********************
  2690.  
  2691.  
  2692.  
  2693.